Rename and cleanup some CMake options

This commit is contained in:
Denis Blank 2017-11-13 13:32:16 +01:00
parent 2ddc2477bb
commit b54bb80147
7 changed files with 58 additions and 31 deletions

View File

@ -23,6 +23,7 @@ matrix:
env:
- COMPILER=g++-6
- NO_EXCEPTIONS=OFF
- WITH_AWAIT=OFF
- os: linux
compiler: clang
@ -40,6 +41,7 @@ matrix:
env:
- COMPILER=clang++-5.0
- NO_EXCEPTIONS=OFF
- WITH_AWAIT=OFF
- os: linux
compiler: clang
@ -57,6 +59,7 @@ matrix:
env:
- COMPILER=clang++-5.0
- NO_EXCEPTIONS=ON
- WITH_AWAIT=ON
install:
- export CXX=$COMPILER
@ -74,7 +77,7 @@ install:
cd build
# Configure the project and build it
cmake -GNinja -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS -Werror" -DTESTS_NO_EXCEPTIONS=$NO_EXCEPTIONS -DCMAKE_BUILD_TYPE=Debug ..
cmake -GNinja -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS -Werror" -DCTI_CONTINUABLE_WITH_NO_EXCEPTIONS=$NO_EXCEPTIONS -DCTI_CONTINUABLE_WITH_AWAIT=$WITH_AWAIT -DCMAKE_BUILD_TYPE=Debug ..
}
script:

View File

@ -1,16 +1,30 @@
cmake_minimum_required(VERSION 3.2)
project(continuable VERSION 2.0.0 LANGUAGES C CXX)
# Dependencies
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}
IS_TOP_LEVEL_PROJECT)
option(CTI_CONTINUABLE_WITH_TESTS
"Build the continuable unit tests"
${IS_TOP_LEVEL_PROJECT})
option(CTI_CONTINUABLE_WITH_EXAMPLES
"Build the continuable examples"
${IS_TOP_LEVEL_PROJECT})
option(CTI_CONTINUABLE_WITH_NO_EXCEPTIONS
"Disable exception support"
OFF)
option(CTI_CONTINUABLE_WITH_AWAIT
"Enable co_await support"
OFF)
include(cmake/CMakeLists.txt)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if (NOT DEFINED CONTINUABLE_UNIT_TESTS
AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CONTINUABLE_UNIT_TESTS ON)
endif()
include(cmake/CMakeLists.txt)
add_subdirectory(dep)
# continuable-base
@ -73,11 +87,10 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
include(CPack)
# Testing
if (CONTINUABLE_UNIT_TESTS)
# Testing and examples
if (CTI_CONTINUABLE_WITH_TESTS OR CTI_CONTINUABLE_WITH_EXAMPLES)
if (MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
@ -88,6 +101,12 @@ if (CONTINUABLE_UNIT_TESTS)
enable_testing()
add_subdirectory(doc)
add_subdirectory(examples)
add_subdirectory(test)
if (CTI_CONTINUABLE_WITH_TESTS)
add_subdirectory(test)
endif()
if (CTI_CONTINUABLE_WITH_EXAMPLES)
add_subdirectory(examples)
endif()
endif ()

View File

@ -19,7 +19,10 @@ clone_script:
- cmd: git submodule update --init --recursive
before_build:
- cmd: cmake -H. -Bbuild -A%PLATFORM% -DTESTS_NO_EXCEPTIONS=%NO_EXCEPTIONS%
- cmd: >
cmake -H. -Bbuild -A%PLATFORM%
-DCTI_CONTINUABLE_WITH_NO_EXCEPTIONS=%NO_EXCEPTIONS%
-DCTI_CONTINUABLE_WITH_AWAIT=ON
build_script:
- cmd: cmake --build build --config %CONFIGURATION% --target ALL_BUILD -- /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:minimal /maxcpucount:2 /nologo

View File

@ -5,7 +5,7 @@ target_compile_options(continuable-features-warnings
-pedantic
-Wextra)
if (WITH_COROUTINES)
if (CTI_CONTINUABLE_WITH_AWAIT)
target_compile_options(continuable-coroutines
INTERFACE
-fcoroutines-ts)
@ -15,7 +15,7 @@ if (WITH_COROUTINES)
-DCONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
endif()
if (TESTS_NO_EXCEPTIONS)
if (CTI_CONTINUABLE_WITH_NO_EXCEPTIONS)
target_compile_options(continuable-features-noexcept
INTERFACE
-fno-exceptions)

View File

@ -5,7 +5,7 @@ target_compile_options(continuable-features-warnings
-pedantic
-Wextra)
if (TESTS_NO_EXCEPTIONS)
if (CTI_CONTINUABLE_WITH_NO_EXCEPTIONS)
target_compile_options(continuable-features-noexcept
INTERFACE
-fno-exceptions)

View File

@ -19,7 +19,7 @@ target_compile_options(continuable-features-warnings
INTERFACE
/W4)
if (WITH_COROUTINES)
if (CTI_CONTINUABLE_WITH_AWAIT)
target_compile_options(continuable-coroutines
INTERFACE
/await)
@ -29,7 +29,7 @@ if (WITH_COROUTINES)
-DCONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
endif()
if (TESTS_NO_EXCEPTIONS)
if (CTI_CONTINUABLE_WITH_NO_EXCEPTIONS)
target_compile_definitions(continuable-features-noexcept
INTERFACE
-D_HAS_EXCEPTIONS=0)

View File

@ -1,15 +1,17 @@
if(CONTINUABLE_UNIT_TESTS AND NOT TARGET gtest)
add_subdirectory(googletest)
endif()
if(CONTINUABLE_UNIT_TESTS AND NOT TARGET cxx_function)
add_subdirectory(cxx_function)
endif()
if(CONTINUABLE_UNIT_TESTS AND NOT TARGET asio)
add_subdirectory(asio)
endif()
if(NOT TARGET function2)
add_subdirectory(function2)
endif()
if (CTI_CONTINUABLE_WITH_TESTS OR CTI_CONTINUABLE_WITH_EXAMPLES)
if(NOT TARGET gtest)
add_subdirectory(googletest)
endif()
if(NOT TARGET cxx_function)
add_subdirectory(cxx_function)
endif()
if(NOT TARGET asio)
add_subdirectory(asio)
endif()
endif()