Permalink
Browse files

Make it possible to run feature tests on header only parts of HPX

* add_hpx_in_framework_config_test makes HPX and its dependencies
  available to the corresponding feature test.
  • Loading branch information...
Naios committed Jun 22, 2017
1 parent 880cfb7 commit 7586970e859d66c318b28548469f7eba23e89854
Showing with 89 additions and 8 deletions.
  1. +24 −7 CMakeLists.txt
  2. +54 −1 cmake/HPX_AddConfigTest.cmake
  3. +11 −0 cmake/HPX_PerformCxxFeatureTests.cmake
View
@@ -915,7 +915,7 @@ endif()
################################################################################
# Set basic search paths for HPX
################################################################################
include_directories("${PROJECT_SOURCE_DIR}" "${CMAKE_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}")
link_directories(${CMAKE_BINARY_DIR}/lib)
################################################################################
@@ -1546,6 +1546,28 @@ hpx_add_config_define(HPX_HAVE_GIT_COMMIT "\"${HPX_WITH_GIT_COMMIT}\"")
hpx_include(SetOutputPaths)
##############################################################################
################################################################################
# Provide a macro for generating config headers
################################################################################
macro(generate_config_defines_header TARGET_DIRECTORY)
# Generate a defines.hpp to be used in the build directory ...
set(HPX_DEFINES_PREFIX ${HPX_BUILD_PREFIX})
write_config_defines_file(
TEMPLATE "${PROJECT_SOURCE_DIR}/cmake/templates/config_defines.hpp.in"
NAMESPACE default
FILENAME "${TARGET_DIRECTORY}/hpx/config/defines.hpp")
endmacro()
###############################################################################
# Perform the on framework CXX feature tests
###############################################################################
hpx_perform_on_framework_cxx_feature_tests()
################################################################################
# Set basic search paths for the generated HPX headers
################################################################################
include_directories("${CMAKE_BINARY_DIR}")
################################################################################
# Configure compression and other plugins
################################################################################
@@ -1633,12 +1655,7 @@ add_plugin_modules()
################################################################################
# Configure the header to include all compile definitions
################################################################################
# Generate a defines.hpp to be used in the build directory ...
set(HPX_DEFINES_PREFIX ${HPX_BUILD_PREFIX})
write_config_defines_file(
TEMPLATE "${PROJECT_SOURCE_DIR}/cmake/templates/config_defines.hpp.in"
NAMESPACE default
FILENAME "${CMAKE_BINARY_DIR}/hpx/config/defines.hpp")
generate_config_defines_header(${CMAKE_BINARY_DIR})
# Generate a defines.hpp to be used in the install directory ...
set(HPX_DEFINES_PREFIX ${HPX_PREFIX})
@@ -1,5 +1,6 @@
# Copyright (c) 2014 Thomas Heller
# Copyright (c) 2011 Bryce Lelbach
# Copyright (c) 2014 Thomas Heller
# Copyright (c) 2017 Denis Blank
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -127,6 +128,58 @@ macro(add_hpx_config_test variable)
endif()
endmacro()
# Makes it possible to provide a feature test that is able to
# test the compiler to build parts of HPX directly when the given definition
# is defined.
macro(add_hpx_in_framework_config_test variable)
# Generate the config only if the test wasn't executed yet
if(NOT DEFINED ${variable})
# Location to generate the config headers to
set(${variable}_GENERATED_DIR
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/config_tests/header-${variable}")
generate_config_defines_header(${${variable}_GENERATED_DIR})
endif()
set(options)
set(one_value_args)
set(multi_value_args DEFINITIONS INCLUDE_DIRECTORIES COMPILE_DEFINITIONS)
cmake_parse_arguments(${variable} "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
# We call the generic feature test method while modifying some
# existing parsed arguments in order to alter the INCLUDE_DIRECTORIES
# and the COMPILE_DEFINITIONS.
# It's important here not to link the config test against an executable
# because otherwise this will result in unresolved references to the
# HPX library, that wasn't built as of now.
add_hpx_config_test(${variable}
${${variable}_UNPARSED_ARGUMENTS}
DEFINITIONS
${${variable}_DEFINITIONS}
COMPILE_DEFINITIONS
${${variable}_COMPILE_DEFINITIONS}
# We add the definitions we test to the
# existing compile definitions.
${${variable}_DEFINITIONS}
# Add HPX_NO_VERSION_CHECK to make header only
# parts of HPX available without requiring to link
# against the HPX sources.
# We can remove this workaround as soon as CMake 3.6
# is the minimal required version and supports:
# CMAKE_TRY_COMPILE_TARGET_TYPE = STATIC_LIBRARY
# when using try_compile to not to throw errors
# on unresolved symbols.
HPX_NO_VERSION_CHECK
INCLUDE_DIRECTORIES
${${variable}_INCLUDE_DIRECTORIES}
# We add the generated headers to the include dirs
${${variable}_GENERATED_DIR})
if(DEFINED ${variable}_GENERATED_DIR)
# Cleanup the generated header
file(REMOVE_RECURSE "${${variable}_GENERATED_DIR}")
endif()
endmacro()
###############################################################################
macro(hpx_cpuid target variable)
add_hpx_config_test(${variable}
@@ -171,3 +171,14 @@ macro(hpx_perform_cxx_feature_tests)
endif()
endmacro()
################################################################################
# C++ feature tests which require 3. party libraries
# and a present config file to work.
#
# This tests are meant for testing the compiler on the capability
# to compile parts of HPX directly without relying on generic feature tests.
################################################################################
macro(hpx_perform_on_framework_cxx_feature_tests)
hpx_check_for_cxx11_sfinae_expression_complete(
DEFINITIONS HPX_HAVE_CXX11_SFINAE_EXPRESSION_COMPLETE)
endmacro()

0 comments on commit 7586970

Please sign in to comment.