Skip to content

Commit 4921656

Browse files
authored
build: replace target_include_directories with target_sources (#112)
1 parent 09b61b7 commit 4921656

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ include(cmake/CPM.cmake)
1414

1515
# Build the main library
1616
add_library(errors src/error.cpp)
17-
target_include_directories(errors PUBLIC include)
17+
target_sources(
18+
errors PUBLIC
19+
FILE_SET HEADERS
20+
BASE_DIRS include
21+
FILES include/errors/error.hpp
22+
)
1823

1924
# Check if this project is the main project
2025
if(NOT_SUBPROJECT)
@@ -41,11 +46,11 @@ if(NOT_SUBPROJECT)
4146

4247
# Append the main library properties instead of linking the library.
4348
get_target_property(errors_SOURCES errors SOURCES)
44-
get_target_property(errors_INCLUDES errors INCLUDE_DIRECTORIES)
49+
get_target_property(errors_HEADER_DIRS errors HEADER_DIRS)
4550

4651
# Build tests for the main library
4752
add_executable(errors_test test/error_test.cpp ${errors_SOURCES})
48-
target_include_directories(errors_test PRIVATE ${errors_INCLUDES})
53+
target_include_directories(errors_test PRIVATE ${errors_HEADER_DIRS})
4954
target_link_libraries(errors_test PRIVATE Catch2::Catch2WithMain)
5055

5156
# Enable support to check for test coverage

components/format/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
cpmaddpackage("gh:fmtlib/fmt#10.0.0")
22

33
add_library(errors_format src/format.cpp)
4-
target_include_directories(errors_format PUBLIC include)
4+
target_sources(
5+
errors_format PUBLIC
6+
FILE_SET HEADERS
7+
BASE_DIRS include
8+
FILES include/errors/format.hpp
9+
)
510
target_link_libraries(errors_format PUBLIC errors fmt)
611

712
if(NOT_SUBPROJECT)
813
if (BUILD_TESTING)
914
# Append the main library properties instead of linking the library.
1015
get_target_property(errors_format_SOURCES errors_format SOURCES)
11-
get_target_property(errors_format_INCLUDES errors_format INCLUDE_DIRECTORIES)
16+
get_target_property(errors_format_HEADER_DIRS errors_format HEADER_DIRS)
1217
get_target_property(errors_format_LIBRARIES errors_format LINK_LIBRARIES)
1318

1419
# Build tests for the main library
1520
add_executable(errors_format_test test/format_test.cpp ${errors_format_SOURCES})
16-
target_include_directories(errors_format_test PRIVATE ${errors_format_INCLUDES})
21+
target_include_directories(errors_format_test PRIVATE ${errors_format_HEADER_DIRS})
1722
target_link_libraries(errors_format_test PRIVATE Catch2::Catch2WithMain ${errors_format_LIBRARIES})
1823

1924
# Enable support to check for test coverage

0 commit comments

Comments
 (0)