# Initialize ###################################################################################### Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) Find_Package ( GTest ) If ( NOT "${GTest_FOUND}" ) Return ( ) EndIf ( ) # Test Helper ##################################################################################### File ( GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/helper/*.cpp ) Add_Library ( cppmicrohttpd-test-helper STATIC ${SOURCE_FILES} ) Target_Include_Directories ( cppmicrohttpd-test-helper PUBLIC $ $ ) Target_Include_Directories ( cppmicrohttpd-test-helper SYSTEM PUBLIC ${MICROHTTPD_INCLUDE_DIRS} ) Target_Link_Libraries ( cppmicrohttpd-test-helper PUBLIC cppmicrohttpd-objects GMock::GMock ) # Test ############################################################################################ File ( GLOB_RECURSE CPPMICROHTTPD_TEST_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/cppmicrohttpd/*.h ) File ( GLOB_RECURSE CPPMICROHTTPD_TEST_INLINE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/cppmicrohttpd/*.inl ) File ( GLOB_RECURSE CPPMICROHTTPD_TEST_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/cppmicrohttpd/*.cpp ) Add_Executable ( cppmicrohttpd-test EXCLUDE_FROM_ALL ${CPPMICROHTTPD_TEST_HEADER_FILES} ${CPPMICROHTTPD_TEST_INLINE_FILES} ${CPPMICROHTTPD_TEST_SOURCE_FILES} ) Target_Link_Libraries ( cppmicrohttpd-test PUBLIC cppmicrohttpd-test-helper GTest::Main ) # pedantic If ( HAS_PEDANTIC ) Pedantic_Apply_Flags_Target ( cppmicrohttpd-test ALL ) EndIf ( ) # optimization If ( HAS_COTIRE ) Cotire ( cppmicrohttpd-test ) EndIf ( ) # test If ( HAS_CMAKE_TESTS ) Add_CMake_Test ( NAME cppmicrohttpd TARGET cppmicrohttpd-test ) Else ( ) Add_Test ( NAME cppmicrohttpd COMMAND cppmicrohttpd-test ) EndIf ( )