Skip to content

Commit

Permalink
Issue #10 - Scripts to support multiple configurations simultaneously…
Browse files Browse the repository at this point in the history
…: shared static release and debug
  • Loading branch information
vldtecno committed Dec 31, 2017
1 parent f5dea9a commit 33a1ff4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ project (PTN_Engine)

option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)


set(CMAKE_DEBUG_POSTFIX d)
set(CMAKE_DEBUG_POSTFIX _d)
set(CMAKE_STATIC_LIBRARY_PREFIX lib)
set(EXECUTABLE_STATIC_POSTFIX _s)


set (CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -57,6 +57,7 @@ option(BUILD_EXAMPLES "Builds the examples" OFF)
add_subdirectory(PTN_Engine)

if(BUILD_TESTS)
option(INSTALL_TESTS "Install tests" OFF)
find_path(GTEST_ROOT PATH ENV${GTEST_ROOT} NO_DEFAULT_PATH)
enable_testing()
find_package(GTest REQUIRED)
Expand All @@ -65,6 +66,7 @@ if(BUILD_TESTS)
endif(BUILD_TESTS)

if(BUILD_EXAMPLES)
option(INSTALL_EXAMPLES "Install examples" OFF)
add_subdirectory(Examples)
endif(BUILD_EXAMPLES)

Expand Down
12 changes: 11 additions & 1 deletion Examples/Elevator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ file( GLOB_RECURSE Elevator_SRC

add_executable (Elevator ${Elevator_SRC})
target_link_libraries(Elevator PUBLIC PTN_Engine)


if(NOT BUILD_SHARED_LIBS)
set_target_properties(Elevator PROPERTIES SUFFIX ${EXECUTABLE_STATIC_POSTFIX}${CMAKE_EXECUTABLE_SUFFIX})
endif()
set_target_properties(Elevator PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

# Install rules
if(INSTALL_EXAMPLES)
install(TARGETS Elevator
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()



Expand Down
10 changes: 10 additions & 0 deletions Examples/PhoneMenu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ file( GLOB_RECURSE PhoneMenu_SRC
add_executable (PhoneMenu ${PhoneMenu_SRC})
target_link_libraries(PhoneMenu PUBLIC PTN_Engine)

if(NOT BUILD_SHARED_LIBS)
set_target_properties(PhoneMenu PROPERTIES SUFFIX ${EXECUTABLE_STATIC_POSTFIX}${CMAKE_EXECUTABLE_SUFFIX})
endif()
set_target_properties(PhoneMenu PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})


# Install rules
if(INSTALL_EXAMPLES)
install(TARGETS PhoneMenu
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()



11 changes: 10 additions & 1 deletion Tests/BlackBoxTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ add_executable (BlackBoxTest ${BlackBoxTest_SRC})
target_link_libraries(BlackBoxTest PUBLIC
${GTEST_BOTH_LIBRARIES}
PTN_Engine)

if(NOT BUILD_SHARED_LIBS)
set_target_properties(BlackBoxTest PROPERTIES SUFFIX ${EXECUTABLE_STATIC_POSTFIX}${CMAKE_EXECUTABLE_SUFFIX})
endif()
set_target_properties(BlackBoxTest PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

add_custom_command(TARGET BlackBoxTest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${GTEST_ROOT}/bin"
$<TARGET_FILE_DIR:BlackBoxTest>)



# Install rules
if(INSTALL_TESTS)
install(TARGETS BlackBoxTest
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

11 changes: 10 additions & 1 deletion Tests/WhiteBoxTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ target_link_libraries(WhiteBoxTest PUBLIC
${GTEST_BOTH_LIBRARIES}
PTN_Engine)

if(NOT BUILD_SHARED_LIBS)
set_target_properties(WhiteBoxTest PROPERTIES SUFFIX ${EXECUTABLE_STATIC_POSTFIX}${CMAKE_EXECUTABLE_SUFFIX})
endif()
set_target_properties(WhiteBoxTest PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

add_custom_command(TARGET WhiteBoxTest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${GTEST_ROOT}/bin"
$<TARGET_FILE_DIR:WhiteBoxTest>)


# Install rules
if(INSTALL_TESTS)
install(TARGETS WhiteBoxTest
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

0 comments on commit 33a1ff4

Please sign in to comment.