refactor: restructure project to build a library for each book chapter
This commit is contained in:
parent
5a3798a604
commit
dfaee89d56
@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(
|
project(
|
||||||
hello
|
book_exercises
|
||||||
VERSION 0.1.0
|
VERSION 0.1.0
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
@ -19,13 +19,17 @@ include(FetchContent)
|
|||||||
configure_file("${PROJECT_SOURCE_DIR}/include/version.h.in"
|
configure_file("${PROJECT_SOURCE_DIR}/include/version.h.in"
|
||||||
"${PROJECT_BINARY_DIR}/include/version.h")
|
"${PROJECT_BINARY_DIR}/include/version.h")
|
||||||
|
|
||||||
add_executable(hello src/main.cpp src/null.cpp src/constexp.cpp
|
add_subdirectory(chapters)
|
||||||
src/ifswitch.cpp src/initlist.cpp)
|
|
||||||
|
|
||||||
target_compile_features(hello PUBLIC cxx_std_20)
|
add_executable(book_exercises src/main.cpp)
|
||||||
|
|
||||||
target_include_directories(hello PRIVATE "${PROJECT_BINARY_DIR}/include"
|
target_compile_features(book_exercises PUBLIC cxx_std_20)
|
||||||
"${PROJECT_SOURCE_DIR}/include")
|
|
||||||
|
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)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
1
chapters/CMakeLists.txt
Normal file
1
chapters/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(chapter_02)
|
4
chapters/chapter_02/CMakeLists.txt
Normal file
4
chapters/chapter_02/CMakeLists.txt
Normal 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)
|
Reference in New Issue
Block a user