diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e58f9..ad82752 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/cmake/CMakeHelpers.cmake b/cmake/CMakeHelpers.cmake index 0a23905..ab4bc99 100644 --- a/cmake/CMakeHelpers.cmake +++ b/cmake/CMakeHelpers.cmake @@ -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() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index cb74666..0000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -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 ()