From: Jeff Preshing Date: Sat, 6 Feb 2016 04:37:33 +0000 (-0500) Subject: Delete JunctionProjectDefs.cmake; simplify AddSample.cmake and move it to samples X-Git-Url: http://plrg.eecs.uci.edu/git/?p=junction.git;a=commitdiff_plain;h=125c4e5e45715acb0444d77db7dfa384cbaff208;hp=77d3fab30b70ba23f9ffdf681cfe57a1b2e2edc2 Delete JunctionProjectDefs.cmake; simplify AddSample.cmake and move it to samples --- 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/AddSample.cmake b/cmake/AddSample.cmake deleted file mode 100644 index 434cf91..0000000 --- a/cmake/AddSample.cmake +++ /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 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/samples/AddSample.cmake b/samples/AddSample.cmake new file mode 100644 index 0000000..1083977 --- /dev/null +++ b/samples/AddSample.cmake @@ -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}) 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)