The C++ library compiles with or with out header file in CMakeLists.txt. Below one compiles with header in CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
add_library(HeaderTest HeaderTest.cpp HeaderTest.h) ####
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
The library HeaderTest compiles with out HeaderTest.h in CMakeLists.txt ie the below CMakeLists.txt also compiles the library
cmake_minimum_required(VERSION 3.0.0)
add_library(HeaderTest HeaderTest.cpp) ###
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
I understand it is because cpp files includes the header files and header files get compiled when the include pre-processor in cpp file is expanded. But is there an advantage in including header files in CMakeLists.txt? Insights on this is appreciated.