diff options
author | Lee Thomason <leethomason@gmail.com> | 2017-05-19 06:57:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-19 06:57:41 +0300 |
commit | 75382867502c75fd683de337093a81b8d44eae3e (patch) | |
tree | 8a430d79f0be8e84e75d087ef3a9d1d98daa94a0 /CMakeLists.txt | |
parent | 174a5df3a36ffa0a9501c17418d25461011cb550 (diff) | |
parent | 105f32f64df4511270a874f7b426b18399d8e660 (diff) |
Merge pull request #535 from jnguyen75/build-tests-option
Added BUILD_TESTS option to enable/disable xmltest
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f17e4cc..0261048 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,9 +44,12 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") # To build static libs also - Do cmake . -DBUILD_STATIC_LIBS:BOOL=ON
# User can choose not to build shared library by using cmake -DBUILD_SHARED_LIBS:BOOL=OFF
# To build only static libs use cmake . -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
+# To build the tests, use cmake . -DBUILD_TESTS:BOOL=ON
+# To disable the building of the tests, use cmake . -DBUILD_TESTS:BOOL=OFF
option(BUILD_SHARED_LIBS "build as shared library" ON)
option(BUILD_STATIC_LIBS "build as static library" OFF)
+option(BUILD_TESTS "build xmltest" ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
@@ -90,22 +93,24 @@ install(TARGETS tinyxml2_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
-add_executable(xmltest xmltest.cpp)
-if(BUILD_SHARED_LIBS)
- add_dependencies(xmltest tinyxml2)
- target_link_libraries(xmltest tinyxml2)
-else(BUILD_STATIC_LIBS)
- add_dependencies(xmltest tinyxml2_static)
- target_link_libraries(xmltest tinyxml2_static)
+if(BUILD_TESTS)
+ add_executable(xmltest xmltest.cpp)
+ if(BUILD_SHARED_LIBS)
+ add_dependencies(xmltest tinyxml2)
+ target_link_libraries(xmltest tinyxml2)
+ else(BUILD_STATIC_LIBS)
+ add_dependencies(xmltest tinyxml2_static)
+ target_link_libraries(xmltest tinyxml2_static)
+ endif()
+
+ # Copy test resources and create test output directory
+ add_custom_command(TARGET xmltest POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:xmltest>/resources
+ COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:xmltest>/resources/out
+ COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources"
+ )
endif()
-# Copy test resources and create test output directory
-add_custom_command(TARGET xmltest POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:xmltest>/resources
- COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:xmltest>/resources/out
- COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources"
-)
-
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
foreach(p LIB INCLUDE)
@@ -118,8 +123,6 @@ endforeach() configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
-#add_test(xmltest ${SAMPLE_NAME} COMMAND $<TARGET_FILE:${SAMPLE_NAME}>)
-
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|