Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CLHEP
CLHEP
Commits
a9638d06
Commit
a9638d06
authored
Feb 09, 2015
by
Lynn Garren
Browse files
add explicit support for c++1y and c++14
parent
05407638
Changes
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
a9638d06
...
...
@@ -4,6 +4,7 @@
# [-DCMAKE_BUILD_TYPE=Debug|Release|RelWithDebInfo|MinSizeRel]
# [-DCMAKE_C_COMPILER=...] [-DCMAKE_CXX_COMPILER=...]
# [-DCLHEP_BUILD_CXXSTD=ON] (c++11 extensions and thread support)
# [-DCLHEP_BUILD_CXXSTD="-std=c++NN"] (use specified c++ extension and thread support)
# [-DCLHEP_BUILD_DOCS=ON]
# [-DLIB_SUFFIX=64]
# /path/to/source
...
...
ChangeLog
View file @
a9638d06
2015-02-09 Lynn Garren <garren@fnal.gov>
* cmake: recognize -std=c++0x, -std=c++11, -std=c++1y, and -std=c++14
* can set CLHEP_BUILD_CXXSTD to one of these flags
* if CLHEP_BUILD_CXXSTD is "ON", then -std=c++11 is used
==============================
21.11.14 Release CLHEP-2.2.0.4
==============================
...
...
cmake/Modules/ClhepVariables.cmake
View file @
a9638d06
...
...
@@ -85,49 +85,133 @@ macro( clhep_autoconf_variables )
endmacro
(
clhep_autoconf_variables
)
macro
(
_clhep_check_cxxstd
)
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
macro
(
_clhep_verify_cxx0x
)
if
(
${
CMAKE_CXX_COMPILER_ID
}
STREQUAL
"Clang"
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.9
)
message
(
FATAL_ERROR
"c++
11
extension
s are
not available for
${
CMAKE_CXX_COMPILER_ID
}${
CMAKE_CXX_COMPILER_VERSION
}
"
)
message
(
FATAL_ERROR
"c++
0x
extension
is
not available for
${
CMAKE_CXX_COMPILER_ID
}${
CMAKE_CXX_COMPILER_VERSION
}
"
)
else
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11 -pthread -Wno-deprecated-declarations"
)
set
(
HAVE_STDCXX true
)
endif
()
elseif
(
CMAKE_COMPILER_IS_GNUCXX
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3
)
message
(
FATAL_ERROR
"c++11 extensions are not available for
${
CMAKE_CXX_COMPILER
}
"
)
elseif
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7
)
set
(
CMAKE_CXX_FLAGS
"-std=c++0x -pthread -Wno-deprecated-declarations
${
CMAKE_CXX_FLAGS
}
"
)
message
(
FATAL_ERROR
"c++0x extension is not available for
${
CMAKE_CXX_COMPILER
}
"
)
else
()
set
(
HAVE_STDCXX true
)
endif
()
else
()
message
(
STATUS
"clhep_set_compiler_flags: Do not know how to set c++11 extensions for
${
CMAKE_CXX_COMPILER_ID
}
"
)
endif
()
endmacro
(
_clhep_verify_cxx0x
)
macro
(
_clhep_verify_cxx11
)
if
(
${
CMAKE_CXX_COMPILER_ID
}
STREQUAL
"Clang"
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3
)
message
(
FATAL_ERROR
"c++11 extension is not available for
${
CMAKE_CXX_COMPILER_ID
}${
CMAKE_CXX_COMPILER_VERSION
}
"
)
else
()
set
(
HAVE_STDCXX true
)
endif
()
elseif
(
CMAKE_COMPILER_IS_GNUCXX
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7
)
message
(
FATAL_ERROR
"c++11 extension is not available for
${
CMAKE_CXX_COMPILER
}
"
)
else
()
set
(
CMAKE_CXX_FLAGS
"-std=c++11 -pthread -Wno-deprecated-declarations
${
CMAKE_CXX_FLAGS
}
"
)
set
(
HAVE_STDCXX true
)
endif
()
else
()
message
(
STATUS
"clhep_set_compiler_flags: Do not know how to set c++11 extensions for
${
CMAKE_CXX_COMPILER_ID
}
"
)
endif
()
endmacro
(
_clhep_verify_cxx11
)
macro
(
_clhep_verify_cxx1y
)
if
(
${
CMAKE_CXX_COMPILER_ID
}
STREQUAL
"Clang"
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5
)
message
(
FATAL_ERROR
"c++1y extension is not available for
${
CMAKE_CXX_COMPILER_ID
}${
CMAKE_CXX_COMPILER_VERSION
}
"
)
else
()
set
(
HAVE_STDCXX true
)
endif
()
elseif
(
CMAKE_COMPILER_IS_GNUCXX
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9
)
message
(
FATAL_ERROR
"c++1y extension is not available for
${
CMAKE_CXX_COMPILER
}
"
)
else
()
set
(
HAVE_STDCXX true
)
endif
()
else
()
message
(
STATUS
"clhep_set_compiler_flags: Do not know how to set c++1y extensions for
${
CMAKE_CXX_COMPILER_ID
}
"
)
endif
()
endmacro
(
_clhep_verify_cxx1y
)
macro
(
_clhep_verify_cxx14
)
if
(
${
CMAKE_CXX_COMPILER_ID
}
STREQUAL
"Clang"
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5
)
message
(
FATAL_ERROR
"c++14 extension is not available for
${
CMAKE_CXX_COMPILER_ID
}${
CMAKE_CXX_COMPILER_VERSION
}
"
)
else
()
set
(
HAVE_STDCXX true
)
endif
()
elseif
(
CMAKE_COMPILER_IS_GNUCXX
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9
)
message
(
FATAL_ERROR
"c++14 extension is not available for
${
CMAKE_CXX_COMPILER
}
"
)
else
()
set
(
HAVE_STDCXX true
)
endif
()
else
()
message
(
STATUS
"clhep_set_compiler_flags: Do not know how to set c++14 extensions for
${
CMAKE_CXX_COMPILER_ID
}
"
)
endif
()
endmacro
(
_clhep_verify_cxx14
)
macro
(
_clhep_check_cxxstd
)
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
##message(STATUS "_clhep_check_cxxstd debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
##message(STATUS "_clhep_check_cxxstd debug: CLHEP_BUILD_CXXSTD: ${CLHEP_BUILD_CXXSTD}")
set
(
HAVE_STDCXX
)
if
(
"
${
CLHEP_BUILD_CXXSTD
}
"
STREQUAL
"-std=c++0x"
)
_clhep_verify_cxx0x
(
)
elseif
(
"
${
CLHEP_BUILD_CXXSTD
}
"
STREQUAL
"-std=c++11"
)
_clhep_verify_cxx11
()
elseif
(
"
${
CLHEP_BUILD_CXXSTD
}
"
STREQUAL
"-std=c++1y"
)
_clhep_verify_cxx1y
()
elseif
(
"
${
CLHEP_BUILD_CXXSTD
}
"
STREQUAL
"-std=c++14"
)
_clhep_verify_cxx14
()
else
()
# presume -std=c++11
set
(
CLHEP_BUILD_CXXSTD
"-std=c++11"
)
_clhep_verify_cxx11
(
)
endif
()
##message(STATUS "_clhep_check_cxxstd debug: CLHEP_BUILD_CXXSTD HAVE_STDCXX: ${CLHEP_BUILD_CXXSTD} ${HAVE_STDCXX}")
if
(
DEFINED HAVE_STDCXX
)
if
(
${
CMAKE_CXX_COMPILER_ID
}
STREQUAL
"Clang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
CLHEP_BUILD_CXXSTD
}
-pthread -Wno-deprecated-declarations"
)
elseif
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
CMAKE_CXX_FLAGS
"
${
CLHEP_BUILD_CXXSTD
}
-pthread -Wno-deprecated-declarations
${
CMAKE_CXX_FLAGS
}
"
)
else
()
message
(
STATUS
"clhep_set_compiler_flags: Do not know how to set c++11 extensions for
${
CMAKE_CXX_COMPILER_ID
}
"
)
endif
()
endif
()
endmacro
(
_clhep_check_cxxstd
)
macro
(
_clhep_check_for_pthread
)
#message(STATUS "_clhep_check_for_pthread debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message
(
STATUS
"_clhep_check_for_pthread debug: CMAKE_CXX_FLAGS:
${
CMAKE_CXX_FLAGS
}
"
)
set
(
HAVE_STDCXX
)
if
(
NOT
"
${
CMAKE_CXX_FLAGS
}
"
STREQUAL
""
)
string
(
REGEX REPLACE
" "
";"
flag_list
${
CMAKE_CXX_FLAGS
}
)
FOREACH
(
flag
${
flag_list
}
)
#message(STATUS "_clhep_check_for_pthread debug: found flag ${flag}" )
if
(
${
flag
}
STREQUAL
"-std=c++11"
)
set
(
HAVE_STDCXX true
)
if
(
${
flag
}
STREQUAL
"-std=c++0x"
)
_clhep_verify_cxx0x
(
)
elseif
(
${
flag
}
STREQUAL
"-std=c++11"
)
_clhep_verify_cxx11
()
elseif
(
${
flag
}
STREQUAL
"-std=c++1y"
)
set
(
HAVE_STDCXX true
)
elseif
(
${
flag
}
STREQUAL
"-std=c++
0x
"
)
set
(
HAVE_STDCXX true
)
_clhep_verify_cxx1y
(
)
elseif
(
${
flag
}
STREQUAL
"-std=c++
14
"
)
_clhep_verify_cxx14
(
)
endif
()
message
(
STATUS
"
${
flag
}
${
HAVE_STDCXX
}
"
)
ENDFOREACH
(
flag
)
if
(
HAVE_STDCXX
)
if
(
DEFINED
HAVE_STDCXX
)
set
(
CMAKE_CXX_FLAGS
"-pthread
${
CMAKE_CXX_FLAGS
}
"
)
endif
()
#message(STATUS "_clhep_check_for_pthread debug: HAVE_STDCXX ${HAVE_STDCXX}")
#
message(STATUS "_clhep_check_for_pthread debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message
(
STATUS
"_clhep_check_for_pthread debug: CMAKE_CXX_FLAGS:
${
CMAKE_CXX_FLAGS
}
"
)
endif
()
endmacro
(
_clhep_check_for_pthread
)
...
...
@@ -142,7 +226,7 @@ macro( clhep_set_compiler_flags )
_clhep_check_cxxstd
()
message
(
STATUS
"enable c++11 extensions:
${
CMAKE_CXX_FLAGS
}
"
)
else
()
_clhep_check_for_pthread
()
_clhep_check_for_pthread
()
endif
()
#message(STATUS "clhep_set_compiler_flags debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
#message(STATUS "cmake compilers ${CMAKE_CXX_COMPILER} ${CMAKE_C_COMPILER}")
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment