Squashed commit of the following:
commit
fb4c001b0b8709a3505bb044705be8a2cedd84d8
Author: Michael Altizer <mialtize@cisco.com>
Date: Fri Nov 18 11:50:08 2016 -0500
cmake: Correct package name used in HS and HWLOC so that REQUIRED works.
commit
3a543585194bf2c30993cca4247bfd7f6ef88027
Author: Michael Altizer <mialtize@cisco.com>
Date: Fri Nov 18 11:48:20 2016 -0500
cmake: Improve detection and use of CppUTest in non-standard locations
include_directories (${PROJECT_SOURCE_DIR})
if (ENABLE_UNIT_TESTS)
- pkg_check_modules (CPPUTEST REQUIRED cpputest)
include(CTest)
add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND})
add_dependencies (check snort)
--- /dev/null
+
+find_package(PkgConfig)
+pkg_check_modules(PC_CPPUTEST cpputest)
+
+find_path(CPPUTEST_INCLUDE_DIR CppUTest/TestHarness.h
+ HINTS ${PC_CPPUTEST_INCLUDEDIR} ${PC_CPPUTEST_INCLUDE_DIRS})
+
+find_library(CPPUTEST_LIBRARY NAMES CppUTest
+ HINTS ${PC_CPPUTEST_LIBDIR} ${PC_CPPUTEST_LIBRARY_DIRS})
+find_library(CPPUTEST_EXT_LIBRARY NAMES CppUTestExt
+ HINTS ${PC_CPPUTEST_LIBDIR} ${PC_CPPUTEST_LIBRARY_DIRS})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(CppUTest DEFAULT_MSG CPPUTEST_LIBRARY CPPUTEST_EXT_LIBRARY CPPUTEST_INCLUDE_DIR)
+
+if(CPPUTEST_LIBRARY AND CPPUTEST_EXT_LIBRARY)
+ set(CPPUTEST_LIBRARIES ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY})
+endif(CPPUTEST_LIBRARY AND CPPUTEST_EXT_LIBRARY)
+
+mark_as_advanced(CPPUTEST_INCLUDE_DIR CPPUTEST_LIBRARY CPPUTEST_EXT_LIBRARY)
HINTS ${HS_LIBRARIES_DIR} ${PC_HYPERSCAN_LIBDIR} ${PC_HYPERSCAN_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(hs DEFAULT_MSG HS_LIBRARIES HS_INCLUDE_DIRS)
+find_package_handle_standard_args(HS DEFAULT_MSG HS_LIBRARIES HS_INCLUDE_DIRS)
mark_as_advanced(HS_INCLUDE_DIRS HS_LIBRARIES)
HINTS ${PC_HWLOC_LIBDIR} ${PC_HWLOC_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(hwloc DEFAULT_MSG HWLOC_LIBRARIES HWLOC_INCLUDE_DIRS)
+find_package_handle_standard_args(HWLOC DEFAULT_MSG HWLOC_LIBRARIES HWLOC_INCLUDE_DIRS)
mark_as_advanced(HWLOC_INCLUDE_DIRS HWLOC_LIBRARIES)
find_package(PCRE REQUIRED)
find_package(SFBPF REQUIRED)
find_package(ZLIB REQUIRED)
+if (ENABLE_UNIT_TESTS)
+ find_package(CppUTest REQUIRED)
+endif (ENABLE_UNIT_TESTS)
# optional libraries
find_package(LibLZMA QUIET)
macro (add_cpputest testname)
if ( ENABLE_UNIT_TESTS )
add_executable (${testname} EXCLUDE_FROM_ALL ${testname}.cc)
- target_include_directories (${testname} PRIVATE ${CPPUTEST_INCLUDE_DIRS})
+ target_include_directories (${testname} PRIVATE ${CPPUTEST_INCLUDE_DIR})
target_link_libraries (${testname} ${CPPUTEST_LIBRARIES} ${ARGN})
add_test (${testname} ${testname})
add_dependencies ( check ${testname} )