Make Junction installable
authorJeff Preshing <filter-github@preshing.com>
Sat, 6 Feb 2016 16:51:52 +0000 (11:51 -0500)
committerJeff Preshing <filter-github@preshing.com>
Sat, 6 Feb 2016 16:51:52 +0000 (11:51 -0500)
CMakeLists.txt
cmake/modules/FindTurf.cmake

index 27b7a8b1482b524dd5b0c10e76fab98416c6e79b..be8526d4b46b6ce23dea5cafe20b7d6792d78b05 100644 (file)
@@ -6,6 +6,9 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithAsserts;RelWithDebInfo" CACHE INTERNAL "Build configs")
        project(Junction)
     set_property(GLOBAL PROPERTY USE_FOLDERS ON)
     set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithAsserts;RelWithDebInfo" CACHE INTERNAL "Build configs")
        project(Junction)
     set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+    set(JUNCTION_WITH_SAMPLES TRUE CACHE BOOL "Include all Junction samples in generated build system")
+    set(JUNCTION_MAKE_INSTALLABLE TRUE)
+    set(TURF_MAKE_INSTALLABLE TRUE)
 endif()        
 
 # Default values, can be overridden by user
 endif()        
 
 # Default values, can be overridden by user
@@ -86,7 +89,7 @@ if(JUNCTION_WITH_LIBCUCKOO)
 endif()
 
 # If this is the root listfile, add all samples
 endif()
 
 # If this is the root listfile, add all samples
-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+if((CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) AND JUNCTION_WITH_SAMPLES)
     file(GLOB children samples/*)
     foreach(child ${children})
         if(EXISTS "${child}/CMakeLists.txt")
     file(GLOB children samples/*)
     foreach(child ${children})
         if(EXISTS "${child}/CMakeLists.txt")
@@ -114,6 +117,14 @@ add_library(junction ${JUNCTION_FILES})
 # Set include dirs for this library (done last, so it's not inherited by subprojects like Tervel, NBDS).
 include_directories(${JUNCTION_ALL_INCLUDE_DIRS})
 
 # Set include dirs for this library (done last, so it's not inherited by subprojects like Tervel, NBDS).
 include_directories(${JUNCTION_ALL_INCLUDE_DIRS})
 
+# Make installable.
+if(JUNCTION_MAKE_INSTALLABLE)
+    install(TARGETS junction DESTINATION lib)
+    install(DIRECTORY junction/ DESTINATION include/junction FILES_MATCHING PATTERN "*.h")
+    file(GLOB configHeaders "${CMAKE_CURRENT_BINARY_DIR}/include/*.h")
+    install(FILES ${configHeaders} DESTINATION include)
+endif()
+
 # Export include dirs/libraries to parent project if we were invoked using add_subdirectory().
 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     set(JUNCTION_INCLUDE_DIRS "${JUNCTION_INCLUDE_DIRS}" PARENT_SCOPE)
 # Export include dirs/libraries to parent project if we were invoked using add_subdirectory().
 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     set(JUNCTION_INCLUDE_DIRS "${JUNCTION_INCLUDE_DIRS}" PARENT_SCOPE)
index eef27498d200bd305196c7731c9ac260fbcc34e2..d9a684a175645b5c2b2d0d961d3c093cabc6ca70 100644 (file)
@@ -1,25 +1,30 @@
 #----------------------------------------------
 #----------------------------------------------
-# When Turf is found, it's basically as if TurfProjectDefs.cmake was included.
+# This find module locates the Turf *source*.
 #
 #
-# Later, this might find binary packages too.
+# Later, it might find binary packages too.
 #
 # Sets:
 #    TURF_FOUND
 #
 # Sets:
 #    TURF_FOUND
-#    TURF_ROOT - the root folder
+#    TURF_ROOT - the root folder, containing CMakeLists.txt
 #    TURF_INCLUDE_DIRS - pass to include_directories()
 #    TURF_INCLUDE_DIRS - pass to include_directories()
-#    AddTurfTarget() - call this to actually add the target
-#
-# You'll want to set the compiler options before calling AddTurfTarget().
 #----------------------------------------------
 
 #----------------------------------------------
 
-find_path(TURF_ROOT "turf/Core.h" PATHS
-    "${CMAKE_CURRENT_SOURCE_DIR}/../turf"
-    "${CMAKE_SOURCE_DIR}/../turf"
-    "${CMAKE_CURRENT_LIST_DIR}/../../../turf")
-
 if(TURF_ROOT)
 if(TURF_ROOT)
-    set(TURF_FOUND TRUE)
+    get_filename_component(fullPath "${TURF_ROOT}" ABSOLUTE)
+    if(EXISTS "${fullPath}/cmake/turf_config.h.in")
+        set(TURF_FOUND TRUE)
+    endif()
 else()
 else()
+    find_path(TURF_ROOT "cmake/turf_config.h.in" PATHS
+        "${CMAKE_CURRENT_SOURCE_DIR}/../turf"
+        "${CMAKE_SOURCE_DIR}/../turf"
+        "${CMAKE_CURRENT_LIST_DIR}/../../../turf")
+    if(TURF_ROOT)
+        set(TURF_FOUND TRUE)
+    endif()
+endif()
+
+if(NOT TURF_FOUND)
     message("Can't find Turf!")
     if(Turf_FIND_REQUIRED)
         message(FATAL_ERROR "Missing required package Turf")
     message("Can't find Turf!")
     if(Turf_FIND_REQUIRED)
         message(FATAL_ERROR "Missing required package Turf")