Update README to explicitly state that functions must be invertible (fix #16)
[junction.git] / CMakeLists.txt
index 0452094..93cf495 100644 (file)
@@ -6,10 +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)
-    include(cmake/JunctionProjectDefs.cmake)
-    ApplyTurfBuildSettings()
-elseif(NOT JUNCTION_FOUND)
-    message(FATAL_ERROR "You must include cmake/JunctionProjectDefs.cmake before adding this subdirectory")
+    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
@@ -27,8 +26,17 @@ set(JUNCTION_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_
 set(JUNCTION_ALL_INCLUDE_DIRS "${JUNCTION_INCLUDE_DIRS}")
 set(JUNCTION_ALL_LIBRARIES junction)
 set(JUNCTION_ALL_DLLS "")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
 
-# Add turf targets
+# Add turf targets and import its macros since we use them below
+get_filename_component(outerPath "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
+set(TURF_ROOT "${outerPath}/turf" CACHE STRING "Path to Turf")
+include("${TURF_ROOT}/cmake/Macros.cmake")
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+    # If this is the root project, apply build settings here so that
+    # they're applied to all targets
+    ApplyTurfBuildSettings()
+endif()
 add_subdirectory(${TURF_ROOT} turf)
 list(APPEND JUNCTION_ALL_INCLUDE_DIRS ${TURF_INCLUDE_DIRS})
 list(APPEND JUNCTION_ALL_LIBRARIES ${TURF_ALL_LIBRARIES})
@@ -75,8 +83,14 @@ if(JUNCTION_WITH_TERVEL)
     list(APPEND JUNCTION_ALL_LIBRARIES ${TERVEL_LIBRARIES})
 endif()
 
+# Optional: Locate libcuckoo and append it to the list of include dirs/libraries.
+if(JUNCTION_WITH_LIBCUCKOO)
+    find_package(LibCuckoo REQUIRED)
+    list(APPEND JUNCTION_ALL_INCLUDE_DIRS ${LIBCUCKOO_INCLUDE_DIRS})
+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")
@@ -104,6 +118,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})
 
+# 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)