Delete JunctionProjectDefs.cmake; simplify AddSample.cmake and move it to samples
authorJeff Preshing <filter-github@preshing.com>
Sat, 6 Feb 2016 04:37:33 +0000 (23:37 -0500)
committerJeff Preshing <filter-github@preshing.com>
Sat, 6 Feb 2016 04:37:33 +0000 (23:37 -0500)
CMakeLists.txt
cmake/AddSample.cmake [deleted file]
cmake/JunctionProjectDefs.cmake [deleted file]
cmake/modules/FindTurf.cmake
samples/AddSample.cmake [new file with mode: 0644]
samples/MallocTest/CMakeLists.txt
samples/MapCorrectnessTests/CMakeLists.txt
samples/MapMemoryBench/CMakeLists.txt
samples/MapPerformanceTests/CMakeLists.txt
samples/MapScalabilityTests/CMakeLists.txt

index 1f89f5ac14abb2384b0c35af28f48f9bfc17819c..27b7a8b1482b524dd5b0c10e76fab98416c6e79b 100644 (file)
@@ -6,10 +6,6 @@ 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")
 endif()        
 
 # Default values, can be overridden by user
@@ -27,8 +23,16 @@ 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
+find_package(Turf REQUIRED)
+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})
diff --git a/cmake/AddSample.cmake b/cmake/AddSample.cmake
deleted file mode 100644 (file)
index 434cf91..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#---------------------------------------------------------------------------
-# This script is included from the CMakeLists.txt (listfile) of sample applications.
-#---------------------------------------------------------------------------
-
-if(NOT DEFINED PROJECT_NAME)
-    message(FATAL_ERROR "project() should be called before including \"${CMAKE_CURRENT_LIST_FILE}\".")
-endif()
-if(NOT DEFINED SAMPLE_NAME)
-    message(FATAL_ERROR "SAMPLE_NAME should be set before including \"${CMAKE_CURRENT_LIST_FILE}\".")
-endif()
-
-# Were we included from the root listfile?
-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-    # Yes, it's the root.
-    include("${CMAKE_CURRENT_LIST_DIR}/JunctionProjectDefs.cmake")
-    ApplyTurfBuildSettings()
-    add_subdirectory(${JUNCTION_ROOT} junction)
-elseif(NOT JUNCTION_FOUND)
-    # No, it was added from a parent listfile (via add_subdirectory).
-    # The parent is responsible for finding Junction before adding the sample.
-    # (Or, Junction's listfile is the root, in which case Junction is already found.)
-    message(FATAL_ERROR "JUNCTION_FOUND should already be set when \"${CMAKE_CURRENT_SOURCE_FILE}\" is not the root listfile.")
-endif()
-
-# Define executable target.
-set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.mycompany.\${PRODUCT_NAME:identifier}")
-SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-GetFilesWithSourceGroups(GLOB SAMPLE_FILES ${CMAKE_CURRENT_SOURCE_DIR} *)
-add_executable(${SAMPLE_NAME} MACOSX_BUNDLE ${SAMPLE_FILES})
-set_target_properties(${SAMPLE_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
-set_target_properties(${SAMPLE_NAME} PROPERTIES FOLDER samples)
-install(TARGETS ${SAMPLE_NAME} DESTINATION bin)
-
-# Set include dirs and libraries
-include_directories(${JUNCTION_ALL_INCLUDE_DIRS})
-target_link_libraries(${SAMPLE_NAME} ${JUNCTION_ALL_LIBRARIES})
-AddDLLCopyStep(${SAMPLE_NAME} ${JUNCTION_ALL_DLLS})
diff --git a/cmake/JunctionProjectDefs.cmake b/cmake/JunctionProjectDefs.cmake
deleted file mode 100644 (file)
index cdbe6e8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add cmake/modules to module search path, so subsequent find_package() commands will work.
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")
-
-# FIXME: Implement FindJunction.cmake that other projects can use
-# If this script was invoked from FindJunction.cmake, JUNCTION_ROOT should already be set.
-if(NOT DEFINED JUNCTION_ROOT)
-    get_filename_component(JUNCTION_ROOT ${CMAKE_CURRENT_LIST_DIR}/.. ABSOLUTE)
-endif()
-
-set(JUNCTION_FOUND TRUE)
-set(JUNCTION_INCLUDE_DIRS ${JUNCTION_ROOT})
-
-# Find Turf
-if(NOT TURF_FOUND)
-    set(TURF_WITH_EXCEPTIONS FALSE CACHE BOOL "Enable compiler support for C++ exceptions")
-    find_package(Turf REQUIRED)
-endif()
index 2f97d4df703f964988f5c89c814b32b80ff199a4..eef27498d200bd305196c7731c9ac260fbcc34e2 100644 (file)
 # You'll want to set the compiler options before calling AddTurfTarget().
 #----------------------------------------------
 
-find_path(TURF_ROOT NAMES "CMakeLists.txt" "cmake/TurfProjectDefs.cmake" PATHS
+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)
-    include("${TURF_ROOT}/cmake/TurfProjectDefs.cmake")
+    set(TURF_FOUND TRUE)
 else()
     message("Can't find Turf!")
     if(Turf_FIND_REQUIRED)
diff --git a/samples/AddSample.cmake b/samples/AddSample.cmake
new file mode 100644 (file)
index 0000000..1083977
--- /dev/null
@@ -0,0 +1,27 @@
+#---------------------------------------------------------------------------
+# This script is included from the CMakeLists.txt (listfile) of sample applications.
+#---------------------------------------------------------------------------
+
+# Were we included from the root listfile?
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+    # Yes, it's the root.
+    list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake/modules")
+    find_package(Turf REQUIRED)
+    include("${TURF_ROOT}/cmake/Macros.cmake")
+    ApplyTurfBuildSettings()
+    add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/.." junction)
+endif()
+
+# Define executable target.
+set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.mycompany.\${PRODUCT_NAME:identifier}")
+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+GetFilesWithSourceGroups(GLOB SAMPLE_FILES ${CMAKE_CURRENT_SOURCE_DIR} *)
+add_executable(${SAMPLE_NAME} MACOSX_BUNDLE ${SAMPLE_FILES})
+set_target_properties(${SAMPLE_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
+set_target_properties(${SAMPLE_NAME} PROPERTIES FOLDER samples)
+install(TARGETS ${SAMPLE_NAME} DESTINATION bin)
+
+# Set include dirs and libraries
+include_directories(${JUNCTION_ALL_INCLUDE_DIRS})
+target_link_libraries(${SAMPLE_NAME} ${JUNCTION_ALL_LIBRARIES})
+AddDLLCopyStep(${SAMPLE_NAME} ${JUNCTION_ALL_DLLS})
index 9838328344f21e3bc9a24eae906dfbfd7e323ed3..e7774af78111cddce0864749b38869bd1238bc2c 100644 (file)
@@ -7,4 +7,4 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     project(${SAMPLE_NAME})
 endif()    
 
-include(../../cmake/AddSample.cmake)
+include(../AddSample.cmake)
index b1c771cc647d916638a233cde48c84b3c8bb7976..50d61a03521dc2261cb6d531522f0ef295ef38ba 100644 (file)
@@ -9,4 +9,4 @@ endif()
 
 set(TEST_CHECK_MAP_CONTENTS TRUE CACHE BOOL "Validate contents of the map using its iterator")
 set(JUNCTION_USERCONFIG "junction_userconfig.h.in" CACHE STRING "Custom config for ${SAMPLE_NAME}")
-include(../../cmake/AddSample.cmake)
+include(../AddSample.cmake)
index 9838328344f21e3bc9a24eae906dfbfd7e323ed3..e7774af78111cddce0864749b38869bd1238bc2c 100644 (file)
@@ -7,4 +7,4 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     project(${SAMPLE_NAME})
 endif()    
 
-include(../../cmake/AddSample.cmake)
+include(../AddSample.cmake)
index 9838328344f21e3bc9a24eae906dfbfd7e323ed3..e7774af78111cddce0864749b38869bd1238bc2c 100644 (file)
@@ -7,4 +7,4 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     project(${SAMPLE_NAME})
 endif()    
 
-include(../../cmake/AddSample.cmake)
+include(../AddSample.cmake)
index 9838328344f21e3bc9a24eae906dfbfd7e323ed3..e7774af78111cddce0864749b38869bd1238bc2c 100644 (file)
@@ -7,4 +7,4 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     project(${SAMPLE_NAME})
 endif()    
 
-include(../../cmake/AddSample.cmake)
+include(../AddSample.cmake)