Skip to content

Commit

Permalink
Build system ported over to use quickcpplib
Browse files Browse the repository at this point in the history
  • Loading branch information
ned14 committed Jun 14, 2017
1 parent f3b54fa commit b5a6941
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 44 deletions.
File renamed without changes.
40 changes: 14 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
# If necessary bring in the Boost lite cmake tooling
list(FIND CMAKE_MODULE_PATH "boost-lite" boost_lite_idx)
if(${boost_lite_idx} EQUAL -1)
if(EXISTS "${CMAKE_SOURCE_DIR}/../.use_boostish_siblings")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../boost-lite/cmake")
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../.use_boostish_siblings")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../boost-lite/cmake")
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/boost/outcome/boost-lite/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/include/boost/outcome/boost-lite/cmake")
else()
message(FATAL_ERROR "FATAL: A copy of boost-lite cannot be found. Try running 'git submodule update --init --recursive'")
endif()
endif()
include(BoostLiteRequireOutOfSourceBuild)
include(BoostLiteUtils)
include(BoostLitePolicies)
include(cmake/QuickCppLibBootstrap.cmake)
include(QuickCppLibRequireOutOfSourceBuild)
include(QuickCppLibUtils)
include(QuickCppLibPolicies)

# Parse the version we tell cmake directly from the version header file
ParseProjectVersionFromHpp("${CMAKE_CURRENT_SOURCE_DIR}/include/boost/outcome/version.hpp" VERSIONSTRING)
Expand All @@ -23,16 +11,16 @@ project(outcome VERSION ${VERSIONSTRING} LANGUAGES C CXX)
# Also set a *cmake* namespace for this project
set(PROJECT_NAMESPACE boost::)
# Setup this cmake environment for this project
include(BoostLiteSetupProject)
include(QuickCppLibSetupProject)
if(NOT PROJECT_IS_DEPENDENCY)
# This file should be updated with the last git SHA next commit
UpdateRevisionHppFromGit("${CMAKE_CURRENT_SOURCE_DIR}/include/boost/outcome/revision.hpp")
endif()
# Find my library dependencies
find_boostish_library(boost-lite "include/boost/outcome" 1.0 REQUIRED)
find_quickcpplib_library(quickcpplib 1.0 REQUIRED)

# Make an interface only library so dependent CMakeLists can bring in this header-only library
include(BoostLiteMakeHeaderOnlyLibrary)
include(QuickCppLibMakeHeaderOnlyLibrary)

# Make preprocessed editions of this library target
if(NOT PROJECT_IS_DEPENDENCY)
Expand Down Expand Up @@ -72,7 +60,7 @@ if(NOT PROJECT_IS_DEPENDENCY)
endif()
# Preprocess Outcome into a single file for doxygen to grok
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/doc/outcome.hpp"
COMMAND ${PYTHON_EXECUTABLE} ${BoostLiteCMakePath}/../pcpp/pcpp/cmd.py
COMMAND ${PYTHON_EXECUTABLE} ${QuickCppLibCMakePath}/../pcpp/pcpp/cmd.py
-o "${CMAKE_CURRENT_SOURCE_DIR}/doc/outcome.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_DIR}/${PROJECT_NAME}.hpp"
-I .
Expand Down Expand Up @@ -100,10 +88,10 @@ if(NOT PROJECT_IS_DEPENDENCY)
endif()
endif()
endif()
include(BoostLiteMakeDoxygen)
include(QuickCppLibMakeDoxygen)

# Set the standard definitions for these libraries and bring in the all_* helper functions
include(BoostLiteApplyDefaultDefinitions)
include(QuickCppLibApplyDefaultDefinitions)
# Set the C++ features this library requires
all_compile_features(PUBLIC
cxx_alias_templates
Expand All @@ -120,7 +108,7 @@ if(NOT MSVC OR CMAKE_VERSION VERSION_GREATER 3.59)
)
endif()
# Set the library dependencies this library has
target_link_libraries(outcome_hl INTERFACE boost-lite::hl)
target_link_libraries(outcome_hl INTERFACE quickcpplib::hl)

# On POSIX we need to patch linking to stdc++fs into the docs examples
if(DOXYGEN_FOUND AND GCC)
Expand All @@ -131,7 +119,7 @@ endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test" AND NOT PROJECT_IS_DEPENDENCY)
# For all possible configurations of this library, add each test
list_filter(outcome_TESTS EXCLUDE REGEX "test_multiabi.cpp")
include(BoostLiteMakeStandardTests)
include(QuickCppLibMakeStandardTests)
if(TARGET outcome_hl_pch)
target_compile_definitions(outcome_hl_pch PUBLIC BOOST_OUTCOME_ENABLE_ADVANCED=1)
endif()
Expand Down Expand Up @@ -165,5 +153,5 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test" AND NOT PROJECT_IS_DEPENDENCY)
endif()

# Make available this library for install and export
include(BoostLiteMakeInstall)
include(BoostLiteMakeExport)
include(QuickCppLibMakeInstall)
include(QuickCppLibMakeExport)
37 changes: 37 additions & 0 deletions cmake/QuickCppLibBootstrap.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
# If necessary bring in the quickcpplib cmake tooling
list(FIND CMAKE_MODULE_PATH "quickcpplib/cmake" quickcpplib_idx)
if(${quickcpplib_idx} EQUAL -1)
# CMAKE_SOURCE_DIR is the very topmost parent cmake project
# CMAKE_CURRENT_SOURCE_DIR is the current cmake subproject

# If there is a magic .quickcpplib_use_siblings directory above the topmost project, use sibling edition
if(EXISTS "${CMAKE_SOURCE_DIR}/../.quickcpplib_use_siblings")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../quickcpplib/cmake")
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules")
# Read in .gitmodules and look for myself
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules" GITMODULESCONTENTS)
if(GITMODULESCONTENTS MATCHES ".*\\n?\\[submodule \"([^\"]+\\/quickcpplib)\"\\]")
set(quickcpplibpath "${CMAKE_MATCH_1}")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${quickcpplibpath}/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/${quickcpplibpath}/cmake")
else()
message(WARNING "WARNING: ${quickcpplibpath}/cmake does not exist, attempting git submodule update --init --recursive ...")
include(FindGit)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${quickcpplibpath}/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/${quickcpplibpath}/cmake")
else()
message(FATAL_ERROR "FATAL: ${quickcpplibpath}/cmake does not exist and git submodule update --init --recursive did not make it available, bailing out")
endif()
endif()
else()
message(FATAL_ERROR "FATAL: A copy of quickcpplib cannot be found, and cannot find a quickcpplib submodule in this git repository")
endif()
else()
message(FATAL_ERROR "FATAL: A copy of quickcpplib cannot be found, and there are no git submodules to search")
endif()
endif()
message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
2 changes: 1 addition & 1 deletion include/boost/outcome/quickcpplib
6 changes: 3 additions & 3 deletions include/boost/outcome/revision.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
#define BOOST_OUTCOME_PREVIOUS_COMMIT_REF 127812aee9d6cdbb53a2f889ea58c89d4fc4b4e5
#define BOOST_OUTCOME_PREVIOUS_COMMIT_DATE "2017-05-27 14:24:26 +00:00"
#define BOOST_OUTCOME_PREVIOUS_COMMIT_UNIQUE 127812ae
#define BOOST_OUTCOME_PREVIOUS_COMMIT_REF f3b54fae4dde722ca47b1a8bba6cf5dd3230b119
#define BOOST_OUTCOME_PREVIOUS_COMMIT_DATE "2017-06-13 23:02:50 +00:00"
#define BOOST_OUTCOME_PREVIOUS_COMMIT_UNIQUE f3b54fae
14 changes: 0 additions & 14 deletions send_to_wandbox.sh

This file was deleted.

0 comments on commit b5a6941

Please sign in to comment.