CMake: properly include examples and tests with macro (added unit_test_framework dependency for unit tests)
This commit is contained in:
1 parent
dabf32a668
commit
7514c82c92
3 files changed
+15
-8
No files matched your search
+6
-2
@@ -150,6 +150,10 @@ if (BUILD_TESTS OR BUILD_EXAMPLES)
|
||||
list (APPEND WEBSOCKETPP_BOOST_LIBS random)
|
||||
endif()
|
||||
|
||||
if (BUILD_TESTS)
|
||||
list (APPEND WEBSOCKETPP_BOOST_LIBS unit_test_framework)
|
||||
endif()
|
||||
|
||||
############ Dependencies
|
||||
|
||||
# Set BOOST_ROOT env variable or pass with cmake -DBOOST_ROOT=path.
|
||||
@@ -221,12 +225,12 @@ add_subdirectory (websocketpp)
|
||||
|
||||
# Add examples
|
||||
if (BUILD_EXAMPLES)
|
||||
add_subdirectory (examples)
|
||||
include_subdirs ("examples")
|
||||
endif ()
|
||||
|
||||
# Add tests
|
||||
if (BUILD_TESTS)
|
||||
add_subdirectory (test)
|
||||
include_subdirs ("test")
|
||||
endif ()
|
||||
|
||||
print_used_build_config()
|
||||
|
||||
@@ -76,3 +76,12 @@ endmacro ()
|
||||
macro (link_openssl)
|
||||
target_link_libraries (${TARGET_NAME} ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
|
||||
endmacro ()
|
||||
|
||||
macro (include_subdirs PARENT)
|
||||
file (GLOB SDIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PARENT}/*")
|
||||
foreach (SUBDIR ${SDIRS})
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/CMakeLists.txt")
|
||||
add_subdirectory ("${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
endmacro()
|
||||
@@ -1,6 +0,0 @@
|
||||
file (GLOB SDIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
|
||||
foreach (SUBDIR ${SDIRS})
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/CMakeLists.txt")
|
||||
add_subdirectory (${SUBDIR})
|
||||
endif ()
|
||||
endforeach ()
|
||||
Reference in new issue
Block a user