cmake_minimum_required(VERSION 3.28) # define CXX interface library # define target & alias (for other projects consuming the "source-tree") add_library(iue-other_honly INTERFACE) # define sources of target target_sources(iue-other_honly INTERFACE FILE_SET public_headers TYPE HEADERS BASE_DIRS ${PROJECT_SOURCE_DIR} FILES func.hpp func.detail.hpp) # define installation step install(TARGETS iue-other_honly EXPORT iue-other-export FILE_SET public_headers DESTINATION "./") # define test if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL) add_executable(iue-other_honly.test func.test.cpp) target_link_libraries(iue-other_honly.test iue-other_honly) add_test(NAME iue-other_honly.test COMMAND iue-other_honly.test) endif() # define CXX normal library # define target & alias (for other projects consuming the "source-tree") add_library(iue-other_lib) # define sources of target target_sources(iue-other_lib PRIVATE library.cpp PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS ${PROJECT_SOURCE_DIR} FILES library.hpp) # define installation step install(TARGETS iue-other_lib EXPORT iue-other-export FILE_SET public_headers DESTINATION "./" LIBRARY DESTINATION "./") # define test if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL) add_executable(iue-other_lib.test library.test.cpp) target_link_libraries(iue-other_lib.test iue-other_lib) add_test(NAME iue-other_lib.test COMMAND iue-other_lib.test) endif() # export targets for consuming cmake projects # generate and install a .cmake file to allow dependend projects consuming the "install-tree" to import all targets install(EXPORT iue-other-export DESTINATION "iue-other" ) # allow dependend projects consuming the "build-tree" to use all targets export(EXPORT iue-other-export)