]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #712 in SNORT/snort3 from cmake_cpputest to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Fri, 18 Nov 2016 18:40:01 +0000 (13:40 -0500)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Fri, 18 Nov 2016 18:40:01 +0000 (13:40 -0500)
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

CMakeLists.txt
cmake/FindCppUTest.cmake [new file with mode: 0644]
cmake/FindHS.cmake
cmake/FindHWLOC.cmake
cmake/include_libraries.cmake
cmake/macros.cmake

index 3b088f8305a718070292f79564a6045d420e5d1a..f82e9068590ef160c3ada90a309328075aa7f94f 100644 (file)
@@ -44,7 +44,6 @@ include_directories (${PROJECT_BINARY_DIR})
 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)
diff --git a/cmake/FindCppUTest.cmake b/cmake/FindCppUTest.cmake
new file mode 100644 (file)
index 0000000..a1cd33a
--- /dev/null
@@ -0,0 +1,20 @@
+
+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)
index 9e67fb521072aed98561dee7e502709e8acec91b..686701b069bd13e805048f8d3d499c351a85f662 100644 (file)
@@ -10,6 +10,6 @@ find_library(HS_LIBRARIES NAMES hs
     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)
index c3f93bcb2b2296f93429341f92cacaa3eefad653..4c13de66d76e57bec593529b4b88dcf36fa5f64d 100644 (file)
@@ -15,6 +15,6 @@ find_library(HWLOC_LIBRARIES NAMES hwloc
     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)
index 5c3014857715923c24aa364543b397627fe81cb6..b8cf0aaabd2d5145dbe28be4bb1d2eeda631fd33 100644 (file)
@@ -10,6 +10,9 @@ find_package(PCAP REQUIRED)
 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)
index 4bf7ef177b9a3bacc5c7cb0b5e2746bbc15f7517..f6fcedb1680d9bb504358a2595daffa8e12ab32c 100644 (file)
@@ -24,7 +24,7 @@ endmacro (add_shared_library)
 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} )