1
0
Fork 0

refactor: restructure project to build a library for each book chapter

main
mandlm 2023-10-21 11:43:01 +02:00
parent 5a3798a604
commit dfaee89d56
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
11 changed files with 15 additions and 6 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20)
project(
hello
book_exercises
VERSION 0.1.0
LANGUAGES CXX)
@ -19,13 +19,17 @@ include(FetchContent)
configure_file("${PROJECT_SOURCE_DIR}/include/version.h.in"
"${PROJECT_BINARY_DIR}/include/version.h")
add_executable(hello src/main.cpp src/null.cpp src/constexp.cpp
src/ifswitch.cpp src/initlist.cpp)
add_subdirectory(chapters)
target_compile_features(hello PUBLIC cxx_std_20)
add_executable(book_exercises src/main.cpp)
target_include_directories(hello PRIVATE "${PROJECT_BINARY_DIR}/include"
"${PROJECT_SOURCE_DIR}/include")
target_compile_features(book_exercises PUBLIC cxx_std_20)
target_include_directories(
book_exercises PRIVATE "${PROJECT_BINARY_DIR}/include"
"${PROJECT_SOURCE_DIR}/include")
target_link_libraries(book_exercises PRIVATE chapter_02)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
add_subdirectory(tests)

1
chapters/CMakeLists.txt Normal file
View File

@ -0,0 +1 @@
add_subdirectory(chapter_02)

View File

@ -0,0 +1,4 @@
add_library(chapter_02 src/initlist.cpp src/null.cpp src/constexp.cpp
src/ifswitch.cpp)
target_include_directories(chapter_02 PUBLIC include)