Skip to content

CMake enhancements #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,26 @@ file(GLOB platformSources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${pla
source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_})

# create the lib
add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_})
add_library(UnitTest++ STATIC ${sources_} ${platformSources_})

if(${UTPP_USE_PLUS_SIGN})
set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++)
endif()

if(${UTPP_USE_PLUS_SIGN})
set (UTPP_INSTALL_DESTINATION "include/UnitTest++")
else()
set (UTPP_INSTALL_DESTINATION "include/UnitTestPP")
endif()


# indicate where to find includes during build and after installation
target_include_directories(UnitTest++ PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${UTPP_INSTALL_DESTINATION}>
)


# build the test runner
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h)
Expand All @@ -77,7 +91,7 @@ add_executable(TestUnitTest++ ${TEST_SRCS})
include_directories(.)

if(${UTPP_USE_PLUS_SIGN})
set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++)
set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++)
endif()

target_link_libraries(TestUnitTest++ UnitTest++)
Expand All @@ -94,16 +108,13 @@ endif()
# add install targets
# need a custom install path?
# define CMAKE_INSTALL_PREFIX to change root folder
if(${UTPP_USE_PLUS_SIGN})
set (UTPP_INSTALL_DESTINATION "include/UnitTest++")
else()
set (UTPP_INSTALL_DESTINATION "include/UnitTestPP")
endif()

set(config_install_dir_ lib${LIB_SUFFIX}/cmake/${PROJECT_NAME})
set(targets_export_name_ "${PROJECT_NAME}Targets")

install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib${LIB_SUFFIX})
install(TARGETS UnitTest++ EXPORT "${targets_export_name_}"
ARCHIVE DESTINATION lib${LIB_SUFFIX}
LIBRARY DESTINATION lib${LIB_SUFFIX}
RUNTIME DESTINATION bin)
install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION})
install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_})
install(FILES cmake/UnitTest++Config.cmake DESTINATION "${config_install_dir_}")
Expand Down