Skip to content

Commit dc1903b

Browse files
committed
Move catch around to allow tests not using catch.
Add better public header support.
1 parent 6a0b12a commit dc1903b

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

cmake/idi/functions/idi_add_sources.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,9 @@ endmacro()
6060
function(idi_add_public_includes)
6161
set(FILE_LIST "")
6262
__process_source_files(${ARGN})
63+
# Public headers go into both file sets:
64+
# - core_includes: used by static-library installs (all headers)
65+
# - core_public_includes: used by shared-library installs (public only)
6366
target_sources("${CURRENT_LIBRARY_NAME}" PUBLIC FILE_SET core_includes TYPE HEADERS BASE_DIRS ${CURRENT_LIBRARY_DIR}/include FILES ${FILE_LIST})
67+
target_sources("${CURRENT_LIBRARY_NAME}" PUBLIC FILE_SET core_public_includes TYPE HEADERS BASE_DIRS ${CURRENT_LIBRARY_DIR}/include FILES ${FILE_LIST})
6468
endfunction()

cmake/idi/functions/idi_component_test.cmake

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ function(__idi_component_test component_name test_file)
1717
# target_include_directories("${CURRENT_LIBRARY_TEST}" SYSTEM PRIVATE
1818
# "${IDICMAKE_EXTERNAL_LIB_DIR}/Catch2/single_include")
1919

20-
target_link_libraries("${CURRENT_LIBRARY_TEST}" PRIVATE Catch2::Catch2WithMain)
21-
2220
set(ADD_MODE "ADDITIONAL_SOURCES")
2321
set(ADD_CORE true)
22+
set(ADD_CATCH true)
2423

2524
foreach(var IN LISTS ARGN)
2625
if(var STREQUAL "ADDITIONAL_LIBRARIES")
@@ -31,6 +30,8 @@ function(__idi_component_test component_name test_file)
3130
set(ADD_MODE "ADDITIONAL_INCLUDES")
3231
elseif(var STREQUAL "ADDITIONAL_SOURCES")
3332
set(ADD_MODE "ADDITIONAL_SOURCES")
33+
elseif(var STREQUAL "NO_CATCH")
34+
set(ADD_CATCH false)
3435
elseif(var STREQUAL "EXCLUDE_CORE")
3536
set(ADD_CORE false)
3637
else()
@@ -49,7 +50,11 @@ function(__idi_component_test component_name test_file)
4950
endif()
5051
endforeach()
5152

52-
if (ADD_CORE)
53+
if(ADD_CATCH)
54+
target_link_libraries("${CURRENT_LIBRARY_TEST}" PRIVATE Catch2::Catch2WithMain)
55+
endif()
56+
57+
if(ADD_CORE)
5358
target_link_libraries("${CURRENT_LIBRARY_TEST}" PUBLIC "${IDICMAKE_CORE}")
5459
list(APPEND __LIBRARY_LIST ${CURRENT_LIBRARY_TEST})
5560
list(APPEND __LIBRARY_LIST ${IDICMAKE_CORE})
@@ -59,7 +64,7 @@ function(__idi_component_test component_name test_file)
5964
endif()
6065

6166
add_test(NAME "${CURRENT_LIBRARY_TEST}" COMMAND "${CURRENT_LIBRARY_TEST}" WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
62-
if (IDICMAKE_IS_SHARED)
67+
if(IDICMAKE_IS_SHARED)
6368
# setting target BUILD_WITH_INSTALL_RPATH to OFF for a shared library
6469
# will make sure that tests link against the build tree RPATH and not
6570
# the system install dir, this lets tests for the .so on linux.

cmake/idi/functions/idi_demo.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ function(__idi_demo demo_name demo_file)
1515
# target_include_directories("${CURRENT_DEMO}" SYSTEM PRIVATE
1616
# "${IDICMAKE_EXTERNAL_LIB_DIR}/Catch2/single_include")
1717

18-
target_link_libraries("${CURRENT_DEMO}" PRIVATE Catch2::Catch2WithMain)
18+
1919

2020
set(ADD_MODE "ADDITIONAL_SOURCES")
2121
set(ADD_CORE true)
22+
set(ADD_CATCH true)
2223

2324
foreach(var IN LISTS ARGN)
2425
if(var STREQUAL "ADDITIONAL_LIBRARIES")
@@ -29,6 +30,8 @@ function(__idi_demo demo_name demo_file)
2930
set(ADD_MODE "ADDITIONAL_INCLUDES")
3031
elseif(var STREQUAL "ADDITIONAL_SOURCES")
3132
set(ADD_MODE "ADDITIONAL_SOURCES")
33+
elseif(var STREQUAL "NO_CATCH")
34+
set(ADD_CATCH false)
3235
elseif(var STREQUAL "EXCLUDE_CORE")
3336
set(ADD_CORE false)
3437
else()
@@ -47,6 +50,10 @@ function(__idi_demo demo_name demo_file)
4750
endif()
4851
endforeach()
4952

53+
if(ADD_CATCH)
54+
target_link_libraries("${CURRENT_DEMO}" PRIVATE Catch2::Catch2WithMain)
55+
endif()
56+
5057
if(ADD_CORE)
5158
target_link_libraries("${CURRENT_DEMO}" PUBLIC "${IDICMAKE_CORE}")
5259
list(APPEND __LIBRARY_LIST ${CURRENT_DEMO})

cmake/idi/version.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
set(IDICMAKE_CPP_FRAMEWORK_VERSION_MAJOR 6)
1414

1515
# Minor increments on backwards compat updates!
16-
set(IDICMAKE_CPP_FRAMEWORK_VERSION_MINOR 0)
16+
set(IDICMAKE_CPP_FRAMEWORK_VERSION_MINOR 2)
1717

1818
# Hot fixes, which should be rare in this case.
1919
set(IDICMAKE_CPP_FRAMEWORK_VERSION_HOTFIX 0)

0 commit comments

Comments
 (0)