I have a project that I put together from a tutorial on a website a few years ago. I have learned that I shouldn’t use GLOB to create a list of files for many reasons but I’m having trouble figuring out the correct way I should add them. Below I’ve included the entire CMakeLists.txt from a small example that compiles the library without error.
For context I’m using the Pitchfork layout and the directory looks like:
nrpp/
build/
<lots of cmake generated stuff>
examples/
badluk.cpp
include/
nrpp/
nrpp.hpp
src/
flmoon.cpp
julday.cpp
TLDR: How should I replace the first line in this CMakeLists.txt file to have a list of include files I can reuse the list instead of manually adding them in multiple places.
file(GLOB HEADER_LIST CONFIGURE_DEPENDS "${nrpp_SOURCE_DIR}/include/nrpp/*.hpp")
add_library(nrpp
flmoon.cpp
julday.cpp
${HEADER_LIST}
)
target_include_directories(nrpp PUBLIC "../include")
target_compile_features(nrpp PUBLIC cxx_std_20)
target_compile_options(nrpp PRIVATE -Wall -Wextra -pedantic -Wshadow)
source_group(
TREE "${PROJECT_SOURCE_DIR}/include"
PREFIX "Header Files"
FILES ${HEADER_LIST}
)
Thannks!
B