Skip to content

Commit

Permalink
Adding possibility to enforce a given C++xx mode (e.g. -DHPX_WITH_CXX…
Browse files Browse the repository at this point in the history
…14=On)
  • Loading branch information
hkaiser committed Jun 8, 2017
1 parent d2884e5 commit df5f069
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Expand Up @@ -994,9 +994,11 @@ hpx_add_target_compile_definition(HPX_DISABLE_ASSERTS
hpx_add_target_compile_definition(BOOST_DISABLE_ASSERTS
CONFIGURATIONS Release RelWithDebInfo MinSizeRelease)

# Make sure we compile in C++11 mode (MSVC uses it automatically)
include(HPX_DetectCppDialect)
hpx_detect_cpp_dialect()
# Make sure we compile in proper C++xx mode (MSVC uses it automatically)
if(NOT MSVC)
include(HPX_DetectCppDialect)
hpx_detect_cpp_dialect()
endif()

################################################################################
# CUDA features
Expand Down
31 changes: 30 additions & 1 deletion cmake/HPX_DetectCppDialect.cmake
Expand Up @@ -6,7 +6,36 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

macro(hpx_detect_cpp_dialect)
if(NOT MSVC)
if(MSVC)
hpx_error("Do not use the macro hpx_detect_cpp_dialect() for builds based on MSVC")
endif()

# enable enforcing a particular C++ mode
if(HPX_WITH_CXX17)
set(CXX_FLAG -std=c++17)
add_definitions(-DBOOST_NO_AUTO_PTR)
hpx_info("C++ mode enforced: C++17")
elseif(HPX_WITH_CXX1Z)
set(CXX_FLAG -std=c++1z)
add_definitions(-DBOOST_NO_AUTO_PTR)
hpx_info("C++ mode enforced: C++1z")
elseif(HPX_WITH_CXX14)
set(CXX_FLAG -std=c++14)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
add_definitions(-DBOOST_NO_CXX14_CONSTEXPR)
endif()
hpx_info("C++ mode enforced: C++14")
elseif(HPX_WITH_CXX1Y)
set(CXX_FLAG -std=c++1y)
hpx_info("C++ mode enforced: C++1y")
elseif(HPX_WITH_CXX11)
set(CXX_FLAG -std=c++11)
hpx_info("C++ mode enforced: C++11")
elseif(HPX_WITH_CXX0X)
set(CXX_FLAG -std=c++0x)
hpx_info("C++ mode enforced: C++0x")
else()
# if no C++ mode is enforced, try to detect which one to use
if(HPX_WITH_CUDA AND NOT HPX_WITH_CUDA_CLANG)
set(CXX_FLAG -std=c++11)
hpx_info("C++ mode used: C++11")
Expand Down

0 comments on commit df5f069

Please sign in to comment.