diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54f0bdf..fa9b9c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,8 @@ -add_library( +add_library(${PROJECT_NAME} ${EXODUSIICPP_LIBRARY_TYPE}) + +target_sources( ${PROJECT_NAME} - ${EXODUSIICPP_LIBRARY_TYPE} + PRIVATE element_block.cpp exception.cpp file.cpp @@ -8,6 +10,16 @@ add_library( side_set.cpp ) +file(GLOB_RECURSE HDRS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/include/exodusIIcpp/*.h) + +target_sources( + ${PROJECT_NAME} + PUBLIC + FILE_SET HEADERS + BASE_DIRS ${CMAKE_SOURCE_DIR}/include + FILES ${HDRS} +) + target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) if(CMAKE_PROJECT_NAME STREQUAL "exodusIIcpp") @@ -56,22 +68,12 @@ if (EXODUSIICPP_INSTALL) install( TARGETS exodusIIcpp - EXPORT exodusIIcppTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - ) - - install( - DIRECTORY ${PROJECT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING PATTERN "*.h" + EXPORT exodusIIcpp-targets + FILE_SET HEADERS ) install( - EXPORT exodusIIcppTargets + EXPORT exodusIIcpp-targets FILE exodusiicpp-targets.cmake NAMESPACE exodusIIcpp:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/exodusIIcpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b1a7046..10149ae 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,15 +2,21 @@ project(exodusIIcpp-test) find_package(GTest REQUIRED) -add_executable(${PROJECT_NAME} - ElementBlock_test.cpp - Error_test.cpp - File_test.cpp - NodeSet_test.cpp - SideSet_test.cpp - main.cpp +add_executable(${PROJECT_NAME}) + +target_sources( + ${PROJECT_NAME} + PRIVATE + ElementBlock_test.cpp + Error_test.cpp + File_test.cpp + NodeSet_test.cpp + SideSet_test.cpp + main.cpp ) + target_code_coverage(${PROJECT_NAME}) + target_sanitization(${PROJECT_NAME}) target_include_directories( diff --git a/tools/exo2yml/CMakeLists.txt b/tools/exo2yml/CMakeLists.txt index 0a878c0..32a36e8 100644 --- a/tools/exo2yml/CMakeLists.txt +++ b/tools/exo2yml/CMakeLists.txt @@ -2,9 +2,9 @@ project(exo2yml LANGUAGES CXX) find_package(yaml-cpp 0.8 REQUIRED) -add_executable(${PROJECT_NAME} - main.cpp -) +add_executable(${PROJECT_NAME}) + +target_sources(${PROJECT_NAME} PRIVATE main.cpp) target_include_directories( ${PROJECT_NAME} @@ -25,7 +25,6 @@ target_link_libraries( if (EXODUSIICPP_INSTALL) install( TARGETS ${PROJECT_NAME} - EXPORT exodusIIcppTargets - RUNTIME DESTINATION bin + EXPORT exodusIIcpp-targets ) endif() diff --git a/tools/yml2exo/CMakeLists.txt b/tools/yml2exo/CMakeLists.txt index be625f3..8a28834 100644 --- a/tools/yml2exo/CMakeLists.txt +++ b/tools/yml2exo/CMakeLists.txt @@ -2,9 +2,9 @@ project(yml2exo LANGUAGES CXX) find_package(yaml-cpp 0.8 REQUIRED) -add_executable(${PROJECT_NAME} - main.cpp -) +add_executable(${PROJECT_NAME}) + +target_sources(${PROJECT_NAME} PRIVATE main.cpp) target_include_directories( ${PROJECT_NAME} @@ -25,7 +25,6 @@ target_link_libraries( if (EXODUSIICPP_INSTALL) install( TARGETS ${PROJECT_NAME} - EXPORT exodusIIcppTargets - RUNTIME DESTINATION bin + EXPORT exodusIIcpp-targets ) endif()