From 125c4e5e45715acb0444d77db7dfa384cbaff208 Mon Sep 17 00:00:00 2001 From: Jeff Preshing Date: Fri, 5 Feb 2016 23:37:33 -0500 Subject: [PATCH] Delete JunctionProjectDefs.cmake; simplify AddSample.cmake and move it to samples --- CMakeLists.txt | 14 +++++++++----- cmake/JunctionProjectDefs.cmake | 17 ----------------- cmake/modules/FindTurf.cmake | 4 ++-- {cmake => samples}/AddSample.cmake | 18 ++++-------------- samples/MallocTest/CMakeLists.txt | 2 +- samples/MapCorrectnessTests/CMakeLists.txt | 2 +- samples/MapMemoryBench/CMakeLists.txt | 2 +- samples/MapPerformanceTests/CMakeLists.txt | 2 +- samples/MapScalabilityTests/CMakeLists.txt | 2 +- 9 files changed, 20 insertions(+), 43 deletions(-) delete mode 100644 cmake/JunctionProjectDefs.cmake rename {cmake => samples}/AddSample.cmake (58%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f89f5a..27b7a8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/JunctionProjectDefs.cmake b/cmake/JunctionProjectDefs.cmake deleted file mode 100644 index cdbe6e8..0000000 --- a/cmake/JunctionProjectDefs.cmake +++ /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() diff --git a/cmake/modules/FindTurf.cmake b/cmake/modules/FindTurf.cmake index 2f97d4d..eef2749 100644 --- a/cmake/modules/FindTurf.cmake +++ b/cmake/modules/FindTurf.cmake @@ -12,13 +12,13 @@ # 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/cmake/AddSample.cmake b/samples/AddSample.cmake similarity index 58% rename from cmake/AddSample.cmake rename to samples/AddSample.cmake index 434cf91..1083977 100644 --- a/cmake/AddSample.cmake +++ b/samples/AddSample.cmake @@ -2,24 +2,14 @@ # 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") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake/modules") + find_package(Turf REQUIRED) + include("${TURF_ROOT}/cmake/Macros.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.") + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/.." junction) endif() # Define executable target. diff --git a/samples/MallocTest/CMakeLists.txt b/samples/MallocTest/CMakeLists.txt index 9838328..e7774af 100644 --- a/samples/MallocTest/CMakeLists.txt +++ b/samples/MallocTest/CMakeLists.txt @@ -7,4 +7,4 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(${SAMPLE_NAME}) endif() -include(../../cmake/AddSample.cmake) +include(../AddSample.cmake) diff --git a/samples/MapCorrectnessTests/CMakeLists.txt b/samples/MapCorrectnessTests/CMakeLists.txt index b1c771c..50d61a0 100644 --- a/samples/MapCorrectnessTests/CMakeLists.txt +++ b/samples/MapCorrectnessTests/CMakeLists.txt @@ -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) diff --git a/samples/MapMemoryBench/CMakeLists.txt b/samples/MapMemoryBench/CMakeLists.txt index 9838328..e7774af 100644 --- a/samples/MapMemoryBench/CMakeLists.txt +++ b/samples/MapMemoryBench/CMakeLists.txt @@ -7,4 +7,4 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(${SAMPLE_NAME}) endif() -include(../../cmake/AddSample.cmake) +include(../AddSample.cmake) diff --git a/samples/MapPerformanceTests/CMakeLists.txt b/samples/MapPerformanceTests/CMakeLists.txt index 9838328..e7774af 100644 --- a/samples/MapPerformanceTests/CMakeLists.txt +++ b/samples/MapPerformanceTests/CMakeLists.txt @@ -7,4 +7,4 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(${SAMPLE_NAME}) endif() -include(../../cmake/AddSample.cmake) +include(../AddSample.cmake) diff --git a/samples/MapScalabilityTests/CMakeLists.txt b/samples/MapScalabilityTests/CMakeLists.txt index 9838328..e7774af 100644 --- a/samples/MapScalabilityTests/CMakeLists.txt +++ b/samples/MapScalabilityTests/CMakeLists.txt @@ -7,4 +7,4 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(${SAMPLE_NAME}) endif() -include(../../cmake/AddSample.cmake) +include(../AddSample.cmake) -- 2.34.1