mirror of
https://github.com/boostorg/yap.git
synced 2026-01-19 04:52:07 +00:00
Dependent compilation of tests, examples ... etc (#100)
* add a project name * opt out of test, example, perf and doc build * compiler definitions for clang * fix build order by setting target depencies * fix streampos namespace * bump benchmark version * remove file since it is part of google benchmark * deactivate tests for google benchmark * add missing ; * add constexpr and variadic templates to compile features * FIX set compile on interface since yap is an interface lib * set cxx 14 as compile feature to compile boost * add missing $ * replace cxx_std_14 by concrete features * add all features to interface_compile_properties * fix interface_compile_properties
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(YAP LANGUAGES CXX)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
##################################################
|
||||
@@ -48,6 +50,7 @@ elseif (NOT std_flag)
|
||||
message(FATAL_ERROR "Only c++14 or later will work")
|
||||
endif ()
|
||||
|
||||
|
||||
##################################################
|
||||
# Sanitizers
|
||||
##################################################
|
||||
@@ -97,24 +100,39 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||
add_definitions(${std_flag} -g -Wall)
|
||||
endif ()
|
||||
|
||||
##################################################
|
||||
# Dependencies
|
||||
##################################################
|
||||
include(dependencies)
|
||||
|
||||
##################################################
|
||||
# yap library
|
||||
##################################################
|
||||
add_library(yap INTERFACE)
|
||||
target_include_directories(yap INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_link_libraries(yap INTERFACE boost)
|
||||
target_compile_features(yap INTERFACE cxx_variadic_templates cxx_constexpr)
|
||||
target_compile_definitions(yap INTERFACE ${constexpr_if_define} BOOST_ALL_NO_LIB=1)
|
||||
if (link_flags)
|
||||
target_link_libraries(yap INTERFACE ${link_flags})
|
||||
target_compile_options(yap INTERFACE ${compile_flags})
|
||||
endif ()
|
||||
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(example)
|
||||
add_subdirectory(perf)
|
||||
add_subdirectory(doc) # Doesn't build docs, just the snippets files.
|
||||
macro(cond_build subdir)
|
||||
set(SUBDIRU "")
|
||||
string(TOUPPER ${subdir} SUBDIRU)
|
||||
option(YAP_BUILD_${SUBDIRU} "Build ${subdir}" ON)
|
||||
if(YAP_BUILD_${SUBDIRU})
|
||||
add_subdirectory(${subdir})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
cond_build(test)
|
||||
|
||||
cond_build(example)
|
||||
|
||||
if (YAP_BUILD_EXAMPLE)
|
||||
cond_build(perf)
|
||||
endif()
|
||||
|
||||
cond_build(doc) # Doesn't build docs, just the snippets files.
|
||||
|
||||
##################################################
|
||||
# Dependencies
|
||||
##################################################
|
||||
include(dependencies)
|
||||
|
||||
@@ -29,26 +29,34 @@ else ()
|
||||
unset(SOURCE_DIR)
|
||||
endif ()
|
||||
|
||||
set_target_properties(boost
|
||||
PROPERTIES
|
||||
INTERFACE_COMPILE_FEATURES cxx_decltype_auto
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
# Google Benchmark
|
||||
###############################################################################
|
||||
execute_process(
|
||||
COMMAND git clone https://github.com/google/benchmark.git
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND git checkout v1.2.0
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/benchmark
|
||||
)
|
||||
|
||||
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/benchmark)
|
||||
if(YAP_BUILD_PERF)
|
||||
execute_process(
|
||||
COMMAND git clone https://github.com/google/benchmark.git
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND git checkout v1.5.0
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/benchmark
|
||||
)
|
||||
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/benchmark)
|
||||
endif()
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Autodiff (see https://github.com/fqiang/autodiff_library)
|
||||
###############################################################################
|
||||
|
||||
if(YAP_BUILD_EXAMPLE)
|
||||
add_library(autodiff_library
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/ActNode.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library/BinaryOPNode.cpp
|
||||
@@ -66,3 +74,4 @@ add_library(autodiff_library
|
||||
target_include_directories(autodiff_library PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/example/autodiff_library)
|
||||
target_compile_definitions(autodiff_library PUBLIC BOOST_ALL_NO_LIB=1)
|
||||
target_link_libraries(autodiff_library boost)
|
||||
endif()
|
||||
|
||||
@@ -37,6 +37,7 @@ if (constexpr_if_define STREQUAL "-DBOOST_NO_CONSTEXPR_IF=0")
|
||||
endif ()
|
||||
|
||||
add_executable(autodiff autodiff_example.cpp)
|
||||
add_dependencies(autodiff autodiff_library)
|
||||
target_link_libraries(autodiff yap boost autodiff_library)
|
||||
if (clang_on_linux)
|
||||
target_link_libraries(autodiff c++)
|
||||
|
||||
@@ -16,6 +16,7 @@ add_code_gen_executable(lazy_vector_perf)
|
||||
|
||||
macro(add_perf_executable name)
|
||||
add_executable(${name} ${name}.cpp)
|
||||
add_dependencies(${name} benchmark)
|
||||
target_link_libraries(${name} yap benchmark)
|
||||
if (clang_on_linux)
|
||||
target_link_libraries(${name} c++)
|
||||
|
||||
@@ -138,4 +138,4 @@ BENCHMARK(BM_eval_as_yap_expr_4x);
|
||||
BENCHMARK(BM_eval_as_cpp_expr);
|
||||
BENCHMARK(BM_eval_as_cpp_expr_4x);
|
||||
|
||||
BENCHMARK_MAIN()
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
@@ -159,4 +159,4 @@ BENCHMARK(BM_make_map_with_boost_assign);
|
||||
BENCHMARK(BM_make_map_manually);
|
||||
BENCHMARK(BM_make_map_inializer_list);
|
||||
|
||||
BENCHMARK_MAIN()
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
@@ -16,6 +16,12 @@ set(coverage_gcda_files)
|
||||
macro(add_test_executable name)
|
||||
add_executable(${name} ${name}.cpp)
|
||||
target_link_libraries(${name} yap)
|
||||
target_compile_features(${name}
|
||||
PRIVATE
|
||||
cxx_constexpr
|
||||
cxx_decltype_auto
|
||||
cxx_auto_type
|
||||
)
|
||||
target_compile_definitions(${name} PRIVATE BOOST_NO_AUTO_PTR)
|
||||
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
|
||||
if (clang_on_linux)
|
||||
|
||||
Reference in New Issue
Block a user