diff options
Diffstat (limited to 'Modules/Compiler')
112 files changed, 1932 insertions, 0 deletions
diff --git a/Modules/Compiler/ADSP-DetermineCompiler.cmake b/Modules/Compiler/ADSP-DetermineCompiler.cmake new file mode 100644 index 0000000..0340f69 --- /dev/null +++ b/Modules/Compiler/ADSP-DetermineCompiler.cmake @@ -0,0 +1,10 @@ + +set(_compiler_id_pp_test "defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)") + +set(_compiler_id_version_compute " +#if defined(__VISUALDSPVERSION__) + /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__VISUALDSPVERSION__>>24) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__VISUALDSPVERSION__>>16 & 0xFF) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__VISUALDSPVERSION__>>8 & 0xFF) +#endif") diff --git a/Modules/Compiler/Absoft-Fortran.cmake b/Modules/Compiler/Absoft-Fortran.cmake new file mode 100644 index 0000000..2e1666f --- /dev/null +++ b/Modules/Compiler/Absoft-Fortran.cmake @@ -0,0 +1,10 @@ +set(CMAKE_Fortran_FLAGS_INIT "") +set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") +set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "") +set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +set(CMAKE_Fortran_MODDIR_FLAG "-YMOD_OUT_DIR=") +set(CMAKE_Fortran_MODPATH_FLAG "-p") +set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree") diff --git a/Modules/Compiler/AppleClang-ASM.cmake b/Modules/Compiler/AppleClang-ASM.cmake new file mode 100644 index 0000000..f52bde0 --- /dev/null +++ b/Modules/Compiler/AppleClang-ASM.cmake @@ -0,0 +1 @@ +include(Compiler/Clang-ASM) diff --git a/Modules/Compiler/AppleClang-C-FeatureTests.cmake b/Modules/Compiler/AppleClang-C-FeatureTests.cmake new file mode 100644 index 0000000..e80b526 --- /dev/null +++ b/Modules/Compiler/AppleClang-C-FeatureTests.cmake @@ -0,0 +1,11 @@ + +set(_cmake_oldestSupported "((__clang_major__ * 100) + __clang_minor__) >= 400") + +set(AppleClang_C11 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L") +set(_cmake_feature_test_c_static_assert "${AppleClang_C11}") +set(AppleClang_C99 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") +set(_cmake_feature_test_c_restrict "${AppleClang_C99}") +set(_cmake_feature_test_c_variadic_macros "${AppleClang_C99}") + +set(AppleClang_C90 "${_cmake_oldestSupported}") +set(_cmake_feature_test_c_function_prototypes "${AppleClang_C90}") diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake new file mode 100644 index 0000000..10454f6 --- /dev/null +++ b/Modules/Compiler/AppleClang-C.cmake @@ -0,0 +1,34 @@ +include(Compiler/Clang) +__compiler_clang(C) + +if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") + + set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") +endif() + +if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) + set(CMAKE_C_STANDARD_DEFAULT 99) +endif() + +macro(cmake_record_c_compile_features) + macro(_get_appleclang_features std_version list) + record_compiler_features(C "${std_version}" ${list}) + endmacro() + + set(_result 0) + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) + _get_appleclang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + if (_result EQUAL 0) + _get_appleclang_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_appleclang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + endif() + endif() +endmacro() diff --git a/Modules/Compiler/AppleClang-CXX-FeatureTests.cmake b/Modules/Compiler/AppleClang-CXX-FeatureTests.cmake new file mode 100644 index 0000000..f67082c --- /dev/null +++ b/Modules/Compiler/AppleClang-CXX-FeatureTests.cmake @@ -0,0 +1,52 @@ + +# No known reference for AppleClang versions. +# Generic reference: http://clang.llvm.org/cxx_status.html +# http://clang.llvm.org/docs/LanguageExtensions.html + +# Note: CXX compiler in Xcode 4.3 does not set __apple_build_version__ and so is +# not recognized as AppleClang. +# Xcode_43 - Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn) +# Xcode_44 - Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn) +# Xcode_45 - Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn) +# Xcode_46 - Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) +# Xcode_50 - Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) +# Xcode_51 - Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn) +# Xcode_60 - Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn) +# Xcode_61 - Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn) + +# There is some non-correspondance. __has_feature(cxx_user_literals) is +# false for AppleClang 4.0 and 4.1, although it is reported as +# supported in the reference link for Clang 3.1. The compiler does not pass +# the CompileFeatures/cxx_user_literals.cpp test. +# cxx_attributes is listed as not supported until Clang 3.3. It works without +# warning with AppleClang 5.0, but issues a gcc-compat warning for +# AppleClang 4.0-4.2. +# cxx_alignof and cxx_alignas tests work for early AppleClang versions, though +# they are listed as supported for Clang 3.3 and later. + +set(_cmake_oldestSupported "((__clang_major__ * 100) + __clang_minor__) >= 400") + +include("${CMAKE_CURRENT_LIST_DIR}/Clang-CXX-TestableFeatures.cmake") + +set(AppleClang51_CXX14 "((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L") +# http://llvm.org/bugs/show_bug.cgi?id=19242 +set(_cmake_feature_test_cxx_attribute_deprecated "${AppleClang51_CXX14}") +# http://llvm.org/bugs/show_bug.cgi?id=19698 +set(_cmake_feature_test_cxx_decltype_auto "${AppleClang51_CXX14}") +set(_cmake_feature_test_cxx_digit_separators "${AppleClang51_CXX14}") +# http://llvm.org/bugs/show_bug.cgi?id=19674 +set(_cmake_feature_test_cxx_generic_lambdas "${AppleClang51_CXX14}") + +set(AppleClang40_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_enum_forward_declarations "${AppleClang40_CXX11}") +set(_cmake_feature_test_cxx_sizeof_member "${AppleClang40_CXX11}") +set(_cmake_feature_test_cxx_extended_friend_declarations "${AppleClang40_CXX11}") +set(_cmake_feature_test_cxx_extern_templates "${AppleClang40_CXX11}") +set(_cmake_feature_test_cxx_func_identifier "${AppleClang40_CXX11}") +set(_cmake_feature_test_cxx_inline_namespaces "${AppleClang40_CXX11}") +set(_cmake_feature_test_cxx_long_long_type "${AppleClang40_CXX11}") +set(_cmake_feature_test_cxx_right_angle_brackets "${AppleClang40_CXX11}") +set(_cmake_feature_test_cxx_variadic_macros "${AppleClang40_CXX11}") + +set(AppleClang_CXX98 "${_cmake_oldestSupported} && __cplusplus >= 199711L") +set(_cmake_feature_test_cxx_template_template_parameters "${AppleClang_CXX98}") diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake new file mode 100644 index 0000000..5194da4 --- /dev/null +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -0,0 +1,44 @@ +include(Compiler/Clang) +__compiler_clang(CXX) + +if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) + # AppleClang 5.0 knows this flag, but does not set a __cplusplus macro greater than 201103L + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) + set(CMAKE_CXX_STANDARD_DEFAULT 98) +endif() + +macro(cmake_record_cxx_compile_features) + macro(_get_appleclang_features std_version list) + record_compiler_features(CXX "${std_version}" ${list}) + endmacro() + + set(_result 0) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) + set(_result 0) + if(CMAKE_CXX14_STANDARD_COMPILE_OPTION) + _get_appleclang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_appleclang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_appleclang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + endif() + endif() +endmacro() diff --git a/Modules/Compiler/AppleClang-DetermineCompiler.cmake b/Modules/Compiler/AppleClang-DetermineCompiler.cmake new file mode 100644 index 0000000..397f95c --- /dev/null +++ b/Modules/Compiler/AppleClang-DetermineCompiler.cmake @@ -0,0 +1,7 @@ + +set(_compiler_id_pp_test "defined(__clang__) && defined(__apple_build_version__)") + +include("${CMAKE_CURRENT_LIST_DIR}/Clang-DetermineCompilerInternal.cmake") + +set(_compiler_id_version_compute "${_compiler_id_version_compute} +# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__apple_build_version__)") diff --git a/Modules/Compiler/Borland-DetermineCompiler.cmake b/Modules/Compiler/Borland-DetermineCompiler.cmake new file mode 100644 index 0000000..ef3083b --- /dev/null +++ b/Modules/Compiler/Borland-DetermineCompiler.cmake @@ -0,0 +1,7 @@ + +set(_compiler_id_pp_test "defined(__BORLANDC__)") + +set(_compiler_id_version_compute " + /* __BORLANDC__ = 0xVRR */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__BORLANDC__>>8) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__BORLANDC__ & 0xFF)") diff --git a/Modules/Compiler/Clang-ASM.cmake b/Modules/Compiler/Clang-ASM.cmake new file mode 100644 index 0000000..16c9c15 --- /dev/null +++ b/Modules/Compiler/Clang-ASM.cmake @@ -0,0 +1,5 @@ +include(Compiler/Clang) + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) + +__compiler_clang(ASM) diff --git a/Modules/Compiler/Clang-C-FeatureTests.cmake b/Modules/Compiler/Clang-C-FeatureTests.cmake new file mode 100644 index 0000000..99c2252 --- /dev/null +++ b/Modules/Compiler/Clang-C-FeatureTests.cmake @@ -0,0 +1,11 @@ + +set(_cmake_oldestSupported "((__clang_major__ * 100) + __clang_minor__) >= 304") + +set(Clang_C11 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L") +set(_cmake_feature_test_c_static_assert "${Clang_C11}") +set(Clang_C99 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") +set(_cmake_feature_test_c_restrict "${Clang_C99}") +set(_cmake_feature_test_c_variadic_macros "${Clang_C99}") + +set(Clang_C90 "${_cmake_oldestSupported}") +set(_cmake_feature_test_c_function_prototypes "${Clang_C90}") diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake new file mode 100644 index 0000000..548d0a5 --- /dev/null +++ b/Modules/Compiler/Clang-C.cmake @@ -0,0 +1,41 @@ +include(Compiler/Clang) +__compiler_clang(C) + +cmake_policy(GET CMP0025 appleClangPolicy) +if(WIN32 OR (APPLE AND NOT appleClangPolicy STREQUAL NEW)) + return() +endif() + +if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") + + set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") +endif() + +if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6) + set(CMAKE_C_STANDARD_DEFAULT 11) +elseif(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_C_STANDARD_DEFAULT 99) +endif() + +macro(cmake_record_c_compile_features) + macro(_get_clang_features std_version list) + record_compiler_features(C "${std_version}" ${list}) + endmacro() + + set(_result 0) + if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) + _get_clang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + if (_result EQUAL 0) + _get_clang_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_clang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + endif() + endif() +endmacro() diff --git a/Modules/Compiler/Clang-CXX-FeatureTests.cmake b/Modules/Compiler/Clang-CXX-FeatureTests.cmake new file mode 100644 index 0000000..df2e1a8 --- /dev/null +++ b/Modules/Compiler/Clang-CXX-FeatureTests.cmake @@ -0,0 +1,34 @@ + +# Reference: http://clang.llvm.org/cxx_status.html +# http://clang.llvm.org/docs/LanguageExtensions.html + +set(_cmake_oldestSupported "((__clang_major__ * 100) + __clang_minor__) >= 304") + +include("${CMAKE_CURRENT_LIST_DIR}/Clang-CXX-TestableFeatures.cmake") + +set(Clang34_CXX14 "((__clang_major__ * 100) + __clang_minor__) >= 304 && __cplusplus > 201103L") +# http://llvm.org/bugs/show_bug.cgi?id=19242 +set(_cmake_feature_test_cxx_attribute_deprecated "${Clang34_CXX14}") +# http://llvm.org/bugs/show_bug.cgi?id=19698 +set(_cmake_feature_test_cxx_decltype_auto "${Clang34_CXX14}") +set(_cmake_feature_test_cxx_digit_separators "${Clang34_CXX14}") +# http://llvm.org/bugs/show_bug.cgi?id=19674 +set(_cmake_feature_test_cxx_generic_lambdas "${Clang34_CXX14}") + +# TODO: Should be supported by Clang 3.1 +set(Clang31_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_enum_forward_declarations "${Clang31_CXX11}") +set(_cmake_feature_test_cxx_sizeof_member "${Clang31_CXX11}") +# TODO: Should be supported by Clang 2.9 +set(Clang29_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_extended_friend_declarations "${Clang29_CXX11}") +set(_cmake_feature_test_cxx_extern_templates "${Clang29_CXX11}") +set(_cmake_feature_test_cxx_func_identifier "${Clang29_CXX11}") +set(_cmake_feature_test_cxx_inline_namespaces "${Clang29_CXX11}") +set(_cmake_feature_test_cxx_long_long_type "${Clang29_CXX11}") +set(_cmake_feature_test_cxx_right_angle_brackets "${Clang29_CXX11}") +set(_cmake_feature_test_cxx_variadic_macros "${Clang29_CXX11}") + +# TODO: Should be supported forever? +set(Clang_CXX98 "${_cmake_oldestSupported} && __cplusplus >= 199711L") +set(_cmake_feature_test_cxx_template_template_parameters "${Clang_CXX98}") diff --git a/Modules/Compiler/Clang-CXX-TestableFeatures.cmake b/Modules/Compiler/Clang-CXX-TestableFeatures.cmake new file mode 100644 index 0000000..b39475c --- /dev/null +++ b/Modules/Compiler/Clang-CXX-TestableFeatures.cmake @@ -0,0 +1,54 @@ + +set(testable_features + cxx_alias_templates + cxx_alignas + cxx_attributes + cxx_auto_type + cxx_binary_literals + cxx_constexpr + cxx_contextual_conversions + cxx_decltype + cxx_decltype_incomplete_return_types + cxx_default_function_template_args + cxx_defaulted_functions + cxx_delegating_constructors + cxx_deleted_functions + cxx_explicit_conversions + cxx_generalized_initializers + cxx_inheriting_constructors + cxx_lambdas + cxx_local_type_template_args + cxx_noexcept + cxx_nonstatic_member_init + cxx_nullptr + cxx_range_for + cxx_raw_string_literals + cxx_reference_qualified_functions + cxx_relaxed_constexpr + cxx_return_type_deduction + cxx_rvalue_references + cxx_static_assert + cxx_strong_enums + cxx_thread_local + cxx_unicode_literals + cxx_unrestricted_unions + cxx_user_literals + cxx_variable_templates + cxx_variadic_templates +) + +foreach(feature ${testable_features}) + set(_cmake_feature_test_${feature} "${_cmake_oldestSupported} && __has_feature(${feature})") +endforeach() + +unset(testable_features) + +set(_cmake_feature_test_cxx_aggregate_default_initializers "${_cmake_oldestSupported} && __has_feature(cxx_aggregate_nsdmi)") + +set(_cmake_feature_test_cxx_trailing_return_types "${_cmake_oldestSupported} && __has_feature(cxx_trailing_return)") +set(_cmake_feature_test_cxx_alignof "${_cmake_oldestSupported} && __has_feature(cxx_alignas)") +set(_cmake_feature_test_cxx_final "${_cmake_oldestSupported} && __has_feature(cxx_override_control)") +set(_cmake_feature_test_cxx_override "${_cmake_oldestSupported} && __has_feature(cxx_override_control)") +set(_cmake_feature_test_cxx_uniform_initialization "${_cmake_oldestSupported} && __has_feature(cxx_generalized_initializers)") +set(_cmake_feature_test_cxx_defaulted_move_initializers "${_cmake_oldestSupported} && __has_feature(cxx_defaulted_functions)") +set(_cmake_feature_test_cxx_lambda_init_captures "${_cmake_oldestSupported} && __has_feature(cxx_init_captures)") diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake new file mode 100644 index 0000000..84b2c74 --- /dev/null +++ b/Modules/Compiler/Clang-CXX.cmake @@ -0,0 +1,53 @@ +include(Compiler/Clang) +__compiler_clang(CXX) + +if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") +endif() + +cmake_policy(GET CMP0025 appleClangPolicy) +if(WIN32 OR (APPLE AND NOT appleClangPolicy STREQUAL NEW)) + return() +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") +elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") +endif() + +if(UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_CXX_STANDARD_DEFAULT 98) +endif() + +macro(cmake_record_cxx_compile_features) + macro(_get_clang_features std_version list) + record_compiler_features(CXX "${std_version}" ${list}) + endmacro() + + set(_result 0) + if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) + _get_clang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + if (_result EQUAL 0) + _get_clang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_clang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + endif() + endif() +endmacro() diff --git a/Modules/Compiler/Clang-DetermineCompiler.cmake b/Modules/Compiler/Clang-DetermineCompiler.cmake new file mode 100644 index 0000000..89df1b6 --- /dev/null +++ b/Modules/Compiler/Clang-DetermineCompiler.cmake @@ -0,0 +1,4 @@ + +set(_compiler_id_pp_test "defined(__clang__)") + +include("${CMAKE_CURRENT_LIST_DIR}/Clang-DetermineCompilerInternal.cmake") diff --git a/Modules/Compiler/Clang-DetermineCompilerInternal.cmake b/Modules/Compiler/Clang-DetermineCompilerInternal.cmake new file mode 100644 index 0000000..08c1230 --- /dev/null +++ b/Modules/Compiler/Clang-DetermineCompilerInternal.cmake @@ -0,0 +1,15 @@ + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__clang_major__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__clang_minor__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100) +# define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(_MSC_VER % 100) +# endif") + +set(_compiler_id_simulate " +# if defined(_MSC_VER) +# define @PREFIX@SIMULATE_ID \"MSVC\" +# endif") diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake new file mode 100644 index 0000000..701089c --- /dev/null +++ b/Modules/Compiler/Clang.cmake @@ -0,0 +1,41 @@ + +#============================================================================= +# Copyright 2002-2012 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_CLANG) + return() +endif() +set(__COMPILER_CLANG 1) + +if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + macro(__compiler_clang lang) + endmacro() +else() + include(Compiler/GNU) + + macro(__compiler_clang lang) + __compiler_gnu(${lang}) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") + set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0) + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ") + set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "-gcc-toolchain ") + else() + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") + set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "--gcc-toolchain=") + endif() + endmacro() +endif() diff --git a/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake b/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..2265e5e --- /dev/null +++ b/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake @@ -0,0 +1,7 @@ + +set(_compiler_id_pp_test "defined(__COMO__)") + +set(_compiler_id_version_compute " + /* __COMO_VERSION__ = VRR */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__COMO_VERSION__ / 100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__COMO_VERSION__ % 100)") diff --git a/Modules/Compiler/Compaq-C-DetermineCompiler.cmake b/Modules/Compiler/Compaq-C-DetermineCompiler.cmake new file mode 100644 index 0000000..02e99dc --- /dev/null +++ b/Modules/Compiler/Compaq-C-DetermineCompiler.cmake @@ -0,0 +1,8 @@ + +set(_compiler_id_pp_test "defined(__DECC)") + +set(_compiler_id_version_compute " + /* __DECC_VER = VVRRTPPPP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__DECC_VER/10000000) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__DECC_VER/100000 % 100) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__DECC_VER % 10000)") diff --git a/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake b/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..c7d0565 --- /dev/null +++ b/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake @@ -0,0 +1,8 @@ + +set(_compiler_id_pp_test "defined(__DECCXX)") + +set(_compiler_id_version_compute " + /* __DECCXX_VER = VVRRTPPPP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__DECCXX_VER/10000000) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__DECCXX_VER/100000 % 100) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__DECCXX_VER % 10000)") diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake new file mode 100644 index 0000000..675560c --- /dev/null +++ b/Modules/Compiler/Cray-C.cmake @@ -0,0 +1 @@ +set(CMAKE_C_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake new file mode 100644 index 0000000..9fb191c --- /dev/null +++ b/Modules/Compiler/Cray-CXX.cmake @@ -0,0 +1 @@ +set(CMAKE_CXX_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/Cray-DetermineCompiler.cmake b/Modules/Compiler/Cray-DetermineCompiler.cmake new file mode 100644 index 0000000..881b82c --- /dev/null +++ b/Modules/Compiler/Cray-DetermineCompiler.cmake @@ -0,0 +1,6 @@ + +set(_compiler_id_pp_test "defined(_CRAYC)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_RELEASE) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_RELEASE_MINOR)") diff --git a/Modules/Compiler/Cray-Fortran.cmake b/Modules/Compiler/Cray-Fortran.cmake new file mode 100644 index 0000000..5d81bb0 --- /dev/null +++ b/Modules/Compiler/Cray-Fortran.cmake @@ -0,0 +1,6 @@ +set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_MODOUT_FLAG -em) +set(CMAKE_Fortran_MODDIR_FLAG -J) +set(CMAKE_Fortran_MODDIR_DEFAULT .) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-f fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-f free") diff --git a/Modules/Compiler/Embarcadero-DetermineCompiler.cmake b/Modules/Compiler/Embarcadero-DetermineCompiler.cmake new file mode 100644 index 0000000..2feedac --- /dev/null +++ b/Modules/Compiler/Embarcadero-DetermineCompiler.cmake @@ -0,0 +1,7 @@ + +set(_compiler_id_pp_test "defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__CODEGEARC_VERSION__>>24 & 0x00FF) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__CODEGEARC_VERSION__>>16 & 0x00FF) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__CODEGEARC_VERSION__ & 0xFFFF)") diff --git a/Modules/Compiler/Fujitsu-DetermineCompiler.cmake b/Modules/Compiler/Fujitsu-DetermineCompiler.cmake new file mode 100644 index 0000000..73ee38c --- /dev/null +++ b/Modules/Compiler/Fujitsu-DetermineCompiler.cmake @@ -0,0 +1,2 @@ + +set(_compiler_id_pp_test "defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)") diff --git a/Modules/Compiler/G95-Fortran.cmake b/Modules/Compiler/G95-Fortran.cmake new file mode 100644 index 0000000..fd84848 --- /dev/null +++ b/Modules/Compiler/G95-Fortran.cmake @@ -0,0 +1,9 @@ +set(CMAKE_Fortran_FLAGS_INIT "") +set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") +set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") +set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +set(CMAKE_Fortran_MODDIR_FLAG "-fmod=") +set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") diff --git a/Modules/Compiler/GHS-C.cmake b/Modules/Compiler/GHS-C.cmake new file mode 100644 index 0000000..e97d62c --- /dev/null +++ b/Modules/Compiler/GHS-C.cmake @@ -0,0 +1,27 @@ +set(CMAKE_C_VERBOSE_FLAG "-v") + +set(CMAKE_C_FLAGS_INIT "") +set(CMAKE_C_FLAGS_DEBUG_INIT "-Odebug -g") +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Ospace") +set(CMAKE_C_FLAGS_RELEASE_INIT "-O") +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O -g") + +set(CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT "-ldebug ${CMAKE_C_FLAGS_DEBUG_INIT}") +set(CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT}") +set(CMAKE_C_GHS_KERNEL_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT}") +set(CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT + "-ldebug ${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}") + +if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) + set (CMAKE_C_GHS_KERNEL_FLAGS_DEBUG "${CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT}" + CACHE STRING "Kernel flags used by the compiler during debug builds.") + set (CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL + "${CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL_INIT}" CACHE STRING + "Kernel flags used by the compiler during release builds for minimum size.") + set (CMAKE_C_GHS_KERNEL_FLAGS_RELEASE + "${CMAKE_C_GHS_KERNEL_FLAGS_RELEASE_INIT}" + CACHE STRING "Kernel flags used by the compiler during release builds.") + set (CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO + "${CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING + "Kernel flags used by the compiler during release builds with debug info.") +endif() diff --git a/Modules/Compiler/GHS-CXX.cmake b/Modules/Compiler/GHS-CXX.cmake new file mode 100644 index 0000000..71a0dec --- /dev/null +++ b/Modules/Compiler/GHS-CXX.cmake @@ -0,0 +1,31 @@ +set(CMAKE_CXX_VERBOSE_FLAG "-v") + +set(CMAKE_CXX_FLAGS_INIT "") +set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Odebug -g") +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Ospace") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O -g") + +set(CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT + "-ldebug ${CMAKE_CXX_FLAGS_DEBUG_INIT}") +set(CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL_INIT + "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}") +set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE_INIT + "${CMAKE_CXX_FLAGS_RELEASE_INIT}") +set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT + "-ldebug ${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}") + +if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) + set (CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG + "${CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT}" + CACHE STRING "Kernel flags used by the compiler during debug builds.") + set (CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL + "${CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL_INIT}" CACHE STRING + "Kernel flags used by the compiler during release builds for minimum size.") + set (CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE + "${CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE_INIT}" + CACHE STRING "Kernel flags used by the compiler during release builds.") + set (CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO + "${CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING + "Kernel flags used by the compiler during release builds with debug info.") +endif() diff --git a/Modules/Compiler/GHS-DetermineCompiler.cmake b/Modules/Compiler/GHS-DetermineCompiler.cmake new file mode 100644 index 0000000..56d24e2 --- /dev/null +++ b/Modules/Compiler/GHS-DetermineCompiler.cmake @@ -0,0 +1,6 @@ +set(_compiler_id_pp_test "defined(__INTEGRITY)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__INTEGRITY_MAJOR_VERSION) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__INTEGRITY_MINOR_VERSION) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEGRITY_PATCH_VERSION)") diff --git a/Modules/Compiler/GNU-ASM.cmake b/Modules/Compiler/GNU-ASM.cmake new file mode 100644 index 0000000..e07401d --- /dev/null +++ b/Modules/Compiler/GNU-ASM.cmake @@ -0,0 +1,6 @@ +# This file is loaded when gcc/g++ is used for assembler files (the "ASM" cmake language) +include(Compiler/GNU) + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) + +__compiler_gnu(ASM) diff --git a/Modules/Compiler/GNU-C-FeatureTests.cmake b/Modules/Compiler/GNU-C-FeatureTests.cmake new file mode 100644 index 0000000..b3fe33f --- /dev/null +++ b/Modules/Compiler/GNU-C-FeatureTests.cmake @@ -0,0 +1,17 @@ + +set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404") + +# GNU 4.7 correctly sets __STDC_VERSION__ to 201112L, but GNU 4.6 sets it +# to 201000L. As the former is strictly greater than the latter, test only +# for the latter. If in the future CMake learns about a C feature which was +# introduced with GNU 4.7, that should test for the correct version, similar +# to the distinction between __cplusplus and __GXX_EXPERIMENTAL_CXX0X__ tests. +set(GNU46_C11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L") +set(_cmake_feature_test_c_static_assert "${GNU46_C11}") +# Since 4.4 at least: +set(GNU44_C99 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") +set(_cmake_feature_test_c_restrict "${GNU44_C99}") +set(_cmake_feature_test_c_variadic_macros "${GNU44_C99}") + +set(GNU_C90 "${_cmake_oldestSupported}") +set(_cmake_feature_test_c_function_prototypes "${GNU_C90}") diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake new file mode 100644 index 0000000..89704e6 --- /dev/null +++ b/Modules/Compiler/GNU-C.cmake @@ -0,0 +1,48 @@ +include(Compiler/GNU) +__compiler_gnu(C) + +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") +elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") +endif() + +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) + set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") +endif() + +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") +elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") +endif() + +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + set(CMAKE_C_STANDARD_DEFAULT 11) +elseif(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) + set(CMAKE_C_STANDARD_DEFAULT 90) +endif() + +macro(cmake_record_c_compile_features) + macro(_get_gcc_features std_version list) + record_compiler_features(C "${std_version}" ${list}) + endmacro() + + set(_result 0) + if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) + _get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + endif() + if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) + if (_result EQUAL 0) + _get_gcc_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_gcc_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + endif() + endif() +endmacro() diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake new file mode 100644 index 0000000..d18adaf --- /dev/null +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -0,0 +1,109 @@ + +# Reference: http://gcc.gnu.org/projects/cxx0x.html +# http://gcc.gnu.org/projects/cxx1y.html + +set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404") + +set(GNU50_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L") +set(_cmake_feature_test_cxx_variable_templates "${GNU50_CXX14}") +set(_cmake_feature_test_cxx_relaxed_constexpr "${GNU50_CXX14}") +set(_cmake_feature_test_cxx_aggregate_default_initializers "${GNU50_CXX14}") + +# GNU 4.9 in c++14 mode sets __cplusplus to 201300L, so don't test for the +# correct value of it below. +# https://patchwork.ozlabs.org/patch/382470/ +set(GNU49_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L") +set(_cmake_feature_test_cxx_contextual_conversions "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_attribute_deprecated "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_decltype_auto "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_digit_separators "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_generic_lambdas "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_lambda_init_captures "${GNU49_CXX14}") +# GNU 4.3 supports binary literals as an extension, but may warn about +# use of extensions prior to GNU 4.9 +# http://stackoverflow.com/questions/16334024/difference-between-gcc-binary-literals-and-c14-ones +set(_cmake_feature_test_cxx_binary_literals "${GNU49_CXX14}") +# The feature below is documented as available in GNU 4.8 (by implementing an +# earlier draft of the standard paper), but that version of the compiler +# does not set __cplusplus to a value greater than 201103L until GNU 4.9: +# http://gcc.gnu.org/onlinedocs/gcc-4.8.2/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros +# http://gcc.gnu.org/onlinedocs/gcc-4.9.0/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros +# So, CMake only reports availability for it with GNU 4.9 or later. +set(_cmake_feature_test_cxx_return_type_deduction "${GNU49_CXX14}") + +# Introduced in GCC 4.8.1 +set(GNU481_CXX11 "((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}") +set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}") +set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}") +# The alignof feature works with GNU 4.7 and -std=c++11, but it is documented +# as available with GNU 4.8, so treat that as true. +set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}") +set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}") +set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") +set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}") +set(GNU47_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}") +# NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor +# release following that (March 2012), and the first minor release to +# support -std=c++11. Prior to that, support for C++11 features is technically +# experiemental and possibly incomplete (see for example the note below about +# cxx_variadic_template_template_parameters) +# GNU does not define __cplusplus correctly before version 4.7. +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=1773 +# __GXX_EXPERIMENTAL_CXX0X__ is defined in prior versions, but may not be +# defined in the future. +set(GNU_CXX0X_DEFINED "(__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))") +set(GNU46_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && ${GNU_CXX0X_DEFINED}") +set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_noexcept "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}") +set(GNU45_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && ${GNU_CXX0X_DEFINED}") +set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") +set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}") +set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}") +set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}") +set(GNU44_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && ${GNU_CXX0X_DEFINED}") +set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_inline_namespaces "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_sizeof_member "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_uniform_initialization "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") +# TODO: If features are ever recorded for GNU 4.3, there should possibly +# be a new feature added like cxx_variadic_template_template_parameters, +# which is implemented by GNU 4.4, but not 4.3. cxx_variadic_templates is +# actually implemented by GNU 4.3, but variadic template template parameters +# 'completes' it, so that is the version we record as having the variadic +# templates capability in CMake. See +# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf +# TODO: Should be supported by GNU 4.3 +set(GNU43_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") +set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_long_long_type "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") +# TODO: Should be supported since GNU 3.4? +set(_cmake_feature_test_cxx_extern_templates "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") +# TODO: Should be supported forever? +set(_cmake_feature_test_cxx_func_identifier "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") +set(_cmake_feature_test_cxx_variadic_macros "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") +set(_cmake_feature_test_cxx_template_template_parameters "${_cmake_oldestSupported} && __cplusplus") diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake new file mode 100644 index 0000000..2dc02f0 --- /dev/null +++ b/Modules/Compiler/GNU-CXX.cmake @@ -0,0 +1,58 @@ +include(Compiler/GNU) +__compiler_gnu(CXX) + +if (WIN32) + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fno-keep-inline-dllexport") + endif() +else() + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2) + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") + endif() +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) + # Supported since 4.3 + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") +endif() + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) + # 4.3 supports 0x variants + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") +endif() + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") +elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) + set(CMAKE_CXX_STANDARD_DEFAULT 98) +endif() + +macro(cmake_record_cxx_compile_features) + macro(_get_gcc_features std_version list) + record_compiler_features(CXX "${std_version}" ${list}) + endmacro() + + set(_result 0) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + _get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) + if (_result EQUAL 0) + _get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_gcc_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + endif() + endif() +endmacro() diff --git a/Modules/Compiler/GNU-DetermineCompiler.cmake b/Modules/Compiler/GNU-DetermineCompiler.cmake new file mode 100644 index 0000000..261f148 --- /dev/null +++ b/Modules/Compiler/GNU-DetermineCompiler.cmake @@ -0,0 +1,9 @@ + +set(_compiler_id_pp_test "defined(__GNUC__)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__GNUC__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__) +# if defined(__GNUC_PATCHLEVEL__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__) +# endif") diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake new file mode 100644 index 0000000..e9c8a59 --- /dev/null +++ b/Modules/Compiler/GNU-Fortran.cmake @@ -0,0 +1,15 @@ +include(Compiler/GNU) +__compiler_gnu(Fortran) + +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") + +# No -DNDEBUG for Fortran. +set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") +set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") + +# No -isystem for Fortran because it will not find .mod files. +unset(CMAKE_INCLUDE_SYSTEM_FLAG_Fortran) + +# Fortran-specific feature flags. +set(CMAKE_Fortran_MODDIR_FLAG -J) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake new file mode 100644 index 0000000..f01255c --- /dev/null +++ b/Modules/Compiler/GNU.cmake @@ -0,0 +1,58 @@ + +#============================================================================= +# Copyright 2002-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_GNU) + return() +endif() +set(__COMPILER_GNU 1) + +macro(__compiler_gnu lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + endif() + if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.2) + set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + endif() + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "--sysroot=") + + # Older versions of gcc (< 4.5) contain a bug causing them to report a missing + # header file as a warning if depfiles are enabled, causing check_header_file + # tests to always succeed. Work around this by disabling dependency tracking + # in try_compile mode. + get_property(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE) + if(NOT _IN_TC OR CMAKE_FORCE_DEPFILES) + # distcc does not transform -o to -MT when invoking the preprocessor + # internally, as it ought to. Work around this bug by setting -MT here + # even though it isn't strictly necessary. + set(CMAKE_DEPFILE_FLAGS_${lang} "-MMD -MT <OBJECT> -MF <DEPFILE>") + endif() + + # Initial configuration flags. + set(CMAKE_${lang}_FLAGS_INIT "") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") + if(NOT APPLE) + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") + endif() +endmacro() diff --git a/Modules/Compiler/HP-ASM.cmake b/Modules/Compiler/HP-ASM.cmake new file mode 100644 index 0000000..b60f207 --- /dev/null +++ b/Modules/Compiler/HP-ASM.cmake @@ -0,0 +1,3 @@ +set(CMAKE_ASM_VERBOSE_FLAG "-v") + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) diff --git a/Modules/Compiler/HP-C-DetermineCompiler.cmake b/Modules/Compiler/HP-C-DetermineCompiler.cmake new file mode 100644 index 0000000..4269799 --- /dev/null +++ b/Modules/Compiler/HP-C-DetermineCompiler.cmake @@ -0,0 +1,8 @@ + +set(_compiler_id_pp_test "defined(__HP_cc)") + +set(_compiler_id_version_compute " + /* __HP_cc = VVRRPP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__HP_cc/10000) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__HP_cc/100 % 100) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__HP_cc % 100)") diff --git a/Modules/Compiler/HP-C.cmake b/Modules/Compiler/HP-C.cmake new file mode 100644 index 0000000..6dddcba --- /dev/null +++ b/Modules/Compiler/HP-C.cmake @@ -0,0 +1,4 @@ +set(CMAKE_C_VERBOSE_FLAG "-v") + +set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") +set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") diff --git a/Modules/Compiler/HP-CXX-DetermineCompiler.cmake b/Modules/Compiler/HP-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..3d4d7e4 --- /dev/null +++ b/Modules/Compiler/HP-CXX-DetermineCompiler.cmake @@ -0,0 +1,8 @@ + +set(_compiler_id_pp_test "defined(__HP_aCC)") + +set(_compiler_id_version_compute " + /* __HP_aCC = VVRRPP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__HP_aCC/10000) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__HP_aCC/100 % 100) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__HP_aCC % 100)") diff --git a/Modules/Compiler/HP-CXX.cmake b/Modules/Compiler/HP-CXX.cmake new file mode 100644 index 0000000..6411dac --- /dev/null +++ b/Modules/Compiler/HP-CXX.cmake @@ -0,0 +1,13 @@ +set(CMAKE_CXX_VERBOSE_FLAG "-v") + +set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") +set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + +# HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98 +# template support. It is known that version 6.25 doesn't need that flag. +# Current assumption: the flag is needed for every version from 3.80 to 4 +# to get it working. +if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4 AND + NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.80) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "+hpxstd98") +endif() diff --git a/Modules/Compiler/HP-Fortran.cmake b/Modules/Compiler/HP-Fortran.cmake new file mode 100644 index 0000000..ad821ab --- /dev/null +++ b/Modules/Compiler/HP-Fortran.cmake @@ -0,0 +1,6 @@ +set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "+source=fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "+source=free") + +set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") +set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") diff --git a/Modules/Compiler/IAR-ASM.cmake b/Modules/Compiler/IAR-ASM.cmake new file mode 100644 index 0000000..66fb052 --- /dev/null +++ b/Modules/Compiler/IAR-ASM.cmake @@ -0,0 +1,14 @@ +# This file is processed when the IAR compiler is used for an assembler file + +include(Compiler/IAR) + +set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <SOURCE> <DEFINES> <FLAGS> -o <OBJECT>") + +if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM") + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) +endif() + + +if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR") + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s90;asm;msa) +endif() diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake new file mode 100644 index 0000000..da29447 --- /dev/null +++ b/Modules/Compiler/IAR-C.cmake @@ -0,0 +1,34 @@ +# This file is processed when the IAR compiler is used for a C file + + +include(Compiler/IAR) + +set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <FLAGS> -o <OBJECT>") +set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>") +set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy") + +# The toolchains for ARM and AVR are quite different: +if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM") + + set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS> ") + +endif() + + +if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR") + set(CMAKE_C_OUTPUT_EXTENSION ".r90") + + if(NOT CMAKE_C_LINK_FLAGS) + set(CMAKE_C_LINK_FLAGS "-Fmotorola") + endif() + + set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <OBJECTS> ") + +endif() + +# add the target specific include directory: +get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH) +get_filename_component(_compilerDir "${_compilerDir}" PATH) +include_directories("${_compilerDir}/inc" ) diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake new file mode 100644 index 0000000..eae9d1b --- /dev/null +++ b/Modules/Compiler/IAR-CXX.cmake @@ -0,0 +1,34 @@ +# This file is processed when the IAR compiler is used for a C++ file + +include(Compiler/IAR) + +set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <FLAGS> -o <OBJECT>") + +set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>") +set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy") + + + +if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM") + + set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS> ") + +endif() + + +if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR") + set(CMAKE_CXX_OUTPUT_EXTENSION ".r90") + if(NOT CMAKE_CXX_LINK_FLAGS) + set(CMAKE_CXX_LINK_FLAGS "-Fmotorola") + endif() + + set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <OBJECTS> ") + +endif() + +# add the target specific include directory: +get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH) +get_filename_component(_compilerDir "${_compilerDir}" PATH) +include_directories("${_compilerDir}/inc") diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake new file mode 100644 index 0000000..c39810a --- /dev/null +++ b/Modules/Compiler/IAR-DetermineCompiler.cmake @@ -0,0 +1,4 @@ + +# IAR Systems compiler for embedded systems. +# http://www.iar.com +set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)") diff --git a/Modules/Compiler/IAR.cmake b/Modules/Compiler/IAR.cmake new file mode 100644 index 0000000..00e4713 --- /dev/null +++ b/Modules/Compiler/IAR.cmake @@ -0,0 +1,46 @@ +# This file is processed when the IAR compiler is used for a C or C++ file +# Documentation can be downloaded here: http://www.iar.com/website1/1.0.1.0/675/1/ +# The initial feature request is here: http://www.cmake.org/Bug/view.php?id=10176 +# It also contains additional links and information. + +if(_IAR_CMAKE_LOADED) + return() +endif() +set(_IAR_CMAKE_LOADED TRUE) + + +get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) +get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) +get_filename_component(_CMAKE_ASM_TOOLCHAIN_LOCATION "${CMAKE_ASM_COMPILER}" PATH) + + +if("${CMAKE_C_COMPILER}" MATCHES "arm" OR "${CMAKE_CXX_COMPILER}" MATCHES "arm" OR "${CMAKE_ASM_COMPILER}" MATCHES "arm") + set(CMAKE_EXECUTABLE_SUFFIX ".elf") + + # For arm, IAR uses the "ilinkarm" linker and "iarchive" archiver: + find_program(CMAKE_IAR_LINKER ilinkarm HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}") + find_program(CMAKE_IAR_AR iarchive HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" ) + + set(IAR_TARGET_ARCHITECTURE "ARM" CACHE STRING "IAR compiler target architecture") +endif() + +if("${CMAKE_C_COMPILER}" MATCHES "avr" OR "${CMAKE_CXX_COMPILER}" MATCHES "avr" OR "${CMAKE_ASM_COMPILER}" MATCHES "avr") + set(CMAKE_EXECUTABLE_SUFFIX ".bin") + + # For AVR and AVR32, IAR uses the "xlink" linker and the "xar" archiver: + find_program(CMAKE_IAR_LINKER xlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" ) + find_program(CMAKE_IAR_AR xar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" ) + + set(IAR_TARGET_ARCHITECTURE "AVR" CACHE STRING "IAR compiler target architecture") + + set(CMAKE_LIBRARY_PATH_FLAG "-I") + +endif() + +if(NOT IAR_TARGET_ARCHITECTURE) + message(FATAL_ERROR "The IAR compiler for this architecture is not yet supported " + " by CMake. Please go to http://www.cmake.org/Bug and enter a feature request there.") +endif() + +set(CMAKE_LINKER "${CMAKE_IAR_LINKER}" CACHE FILEPATH "The IAR linker" FORCE) +set(CMAKE_AR "${CMAKE_IAR_AR}" CACHE FILEPATH "The IAR archiver" FORCE) diff --git a/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake new file mode 100644 index 0000000..899e284 --- /dev/null +++ b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake @@ -0,0 +1,6 @@ + +set(_compiler_id_version_compute " + /* __IBMC__ = VRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__IBMC__/100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__IBMC__/10 % 10) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__IBMC__ % 10)") diff --git a/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake new file mode 100644 index 0000000..73aa2b4 --- /dev/null +++ b/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake @@ -0,0 +1,6 @@ + +set(_compiler_id_version_compute " + /* __IBMCPP__ = VRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__IBMCPP__/100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__IBMCPP__/10 % 10) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__IBMCPP__ % 10)") diff --git a/Modules/Compiler/Intel-ASM.cmake b/Modules/Compiler/Intel-ASM.cmake new file mode 100644 index 0000000..74ceb0a --- /dev/null +++ b/Modules/Compiler/Intel-ASM.cmake @@ -0,0 +1,13 @@ +set(CMAKE_ASM_VERBOSE_FLAG "-v") + +set(CMAKE_ASM_FLAGS_INIT "") +set(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") +set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") +set(CMAKE_ASM_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") + +if(UNIX) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S) +else() + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS asm) +endif() diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake new file mode 100644 index 0000000..1d651e3 --- /dev/null +++ b/Modules/Compiler/Intel-C.cmake @@ -0,0 +1,12 @@ +set(CMAKE_C_VERBOSE_FLAG "-v") + +set(CMAKE_C_FLAGS_INIT "") +set(CMAKE_C_FLAGS_DEBUG_INIT "-g") +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") + +set(CMAKE_DEPFILE_FLAGS_C "-MMD -MT <OBJECT> -MF <DEPFILE>") + +set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") +set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake new file mode 100644 index 0000000..020e862 --- /dev/null +++ b/Modules/Compiler/Intel-CXX.cmake @@ -0,0 +1,12 @@ +set(CMAKE_CXX_VERBOSE_FLAG "-v") + +set(CMAKE_CXX_FLAGS_INIT "") +set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") + +set(CMAKE_DEPFILE_FLAGS_CXX "-MMD -MT <OBJECT> -MF <DEPFILE>") + +set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") +set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/Intel-DetermineCompiler.cmake b/Modules/Compiler/Intel-DetermineCompiler.cmake new file mode 100644 index 0000000..d7e4532 --- /dev/null +++ b/Modules/Compiler/Intel-DetermineCompiler.cmake @@ -0,0 +1,26 @@ + +set(_compiler_id_pp_test "defined(__INTEL_COMPILER) || defined(__ICC)") + +set(_compiler_id_version_compute " + /* __INTEL_COMPILER = VRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__INTEL_COMPILER/100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__INTEL_COMPILER/10 % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEL_COMPILER_UPDATE) +# else +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEL_COMPILER % 10) +# endif +# if defined(__INTEL_COMPILER_BUILD_DATE) + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ +# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__INTEL_COMPILER_BUILD_DATE) +# endif +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100) +# define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(_MSC_VER % 100) +# endif") + +set(_compiler_id_simulate " +# if defined(_MSC_VER) +# define @PREFIX@SIMULATE_ID \"MSVC\" +# endif") diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake new file mode 100644 index 0000000..9ebac5a --- /dev/null +++ b/Modules/Compiler/Intel-Fortran.cmake @@ -0,0 +1,12 @@ +set(CMAKE_Fortran_FLAGS_INIT "") +set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") +set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") +set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +set(CMAKE_Fortran_MODDIR_FLAG "-module ") +set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") + +set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") +set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/MIPSpro-C.cmake b/Modules/Compiler/MIPSpro-C.cmake new file mode 100644 index 0000000..675560c --- /dev/null +++ b/Modules/Compiler/MIPSpro-C.cmake @@ -0,0 +1 @@ +set(CMAKE_C_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/MIPSpro-CXX.cmake b/Modules/Compiler/MIPSpro-CXX.cmake new file mode 100644 index 0000000..9fb191c --- /dev/null +++ b/Modules/Compiler/MIPSpro-CXX.cmake @@ -0,0 +1 @@ +set(CMAKE_CXX_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/MIPSpro-DetermineCompiler.cmake b/Modules/Compiler/MIPSpro-DetermineCompiler.cmake new file mode 100644 index 0000000..9e48553 --- /dev/null +++ b/Modules/Compiler/MIPSpro-DetermineCompiler.cmake @@ -0,0 +1,15 @@ + +set(_compiler_id_pp_test "defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)") + +set(_compiler_id_version_compute " +# if defined(_SGI_COMPILER_VERSION) + /* _SGI_COMPILER_VERSION = VRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_SGI_COMPILER_VERSION/100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_SGI_COMPILER_VERSION/10 % 10) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_SGI_COMPILER_VERSION % 10) +# else + /* _COMPILER_VERSION = VRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_COMPILER_VERSION/100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_COMPILER_VERSION/10 % 10) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_COMPILER_VERSION % 10) +# endif") diff --git a/Modules/Compiler/MIPSpro-Fortran.cmake b/Modules/Compiler/MIPSpro-Fortran.cmake new file mode 100644 index 0000000..ffceea8 --- /dev/null +++ b/Modules/Compiler/MIPSpro-Fortran.cmake @@ -0,0 +1,3 @@ +set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixedform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-freeform") diff --git a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake new file mode 100644 index 0000000..fcedf3c --- /dev/null +++ b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake @@ -0,0 +1,111 @@ + +# Reference: http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx +# http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx +# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx +# http://www.visualstudio.com/en-us/news/vs2015-preview-vs.aspx + + +set(_cmake_oldestSupported "_MSC_VER >= 1600") + +set(MSVC_2015 "_MSC_VER >= 1900") +set(_cmake_feature_test_cxx_alignas "${MSVC_2015}") +set(_cmake_feature_test_cxx_alignof "${MSVC_2015}") +set(_cmake_feature_test_cxx_binary_literals "${MSVC_2015}") +set(_cmake_feature_test_cxx_decltype_auto "${MSVC_2015}") +# Digit separators are not available as of VS 2015 Preview, but a footnote +# says they will be available in the RTM. +set(_cmake_feature_test_cxx_digit_separators "${MSVC_2015}") +set(_cmake_feature_test_cxx_func_identifier "${MSVC_2015}") +set(_cmake_feature_test_cxx_nonstatic_member_init "${MSVC_2015}") +# Microsoft calls this 'rvalue references v3' +set(_cmake_feature_test_cxx_defaulted_move_initializers "${MSVC_2015}") +set(_cmake_feature_test_cxx_generic_lambdas "${MSVC_2015}") +set(_cmake_feature_test_cxx_inheriting_constructors "${MSVC_2015}") +set(_cmake_feature_test_cxx_inline_namespaces "${MSVC_2015}") +set(_cmake_feature_test_cxx_lambda_init_captures "${MSVC_2015}") +set(_cmake_feature_test_cxx_noexcept "${MSVC_2015}") +set(_cmake_feature_test_cxx_return_type_deduction "${MSVC_2015}") +set(_cmake_feature_test_cxx_sizeof_member "${MSVC_2015}") +set(_cmake_feature_test_cxx_thread_local "${MSVC_2015}") +set(_cmake_feature_test_cxx_unicode_literals "${MSVC_2015}") +set(_cmake_feature_test_cxx_unrestricted_unions "${MSVC_2015}") +set(_cmake_feature_test_cxx_user_literals "${MSVC_2015}") +set(_cmake_feature_test_cxx_reference_qualified_functions "${MSVC_2015}") +# "The copies and moves don't interact precisely like the Standard says they +# should. For example, deletion of moves is specified to also suppress +# copies, but Visual C++ in Visual Studio 2013 does not." +# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx +# lists this as 'partial' in 2013 +set(_cmake_feature_test_cxx_deleted_functions "${MSVC_2015}") + +set(MSVC_2013_v30723 "_MSC_FULL_VER >= 180030723") +# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx +# Note 1. While previous version of VisualStudio said they supported these +# they silently produced bad code, and are now marked as having partial +# support in previous versions. The footnote says the support will be complete +# in MSVC 2015, so support the feature for that version, assuming that is true. +# The blog post also says that VS 2013 Update 3 generates an error in cases +# that previously produced bad code. +set(_cmake_feature_test_cxx_generalized_initializers "${MSVC_2013_v30723}") + +set(MSVC_2013 "_MSC_VER >= 1800") +set(_cmake_feature_test_cxx_alias_templates "${MSVC_2013}") +# Microsoft now states they support contextual conversions in 2013 and above. +# See footnote 6 at: +# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx +set(_cmake_feature_test_cxx_contextual_conversions "${MSVC_2013}") +set(_cmake_feature_test_cxx_default_function_template_args "${MSVC_2013}") +set(_cmake_feature_test_cxx_defaulted_functions "${MSVC_2013}") +set(_cmake_feature_test_cxx_delegating_constructors "${MSVC_2013}") +set(_cmake_feature_test_cxx_explicit_conversions "${MSVC_2013}") +set(_cmake_feature_test_cxx_raw_string_literals "${MSVC_2013}") +set(_cmake_feature_test_cxx_uniform_initialization "${MSVC_2013}") +# Support is documented, but possibly partly broken: +# https://msdn.microsoft.com/en-us/library/hh567368.aspx +# http://thread.gmane.org/gmane.comp.lib.boost.devel/244986/focus=245333 +set(_cmake_feature_test_cxx_variadic_templates "${MSVC_2013}") + +set(MSVC_2012 "_MSC_VER >= 1700") +set(_cmake_feature_test_cxx_enum_forward_declarations "${MSVC_2012}") +set(_cmake_feature_test_cxx_final "${MSVC_2012}") +set(_cmake_feature_test_cxx_range_for "${MSVC_2012}") +set(_cmake_feature_test_cxx_strong_enums "${MSVC_2012}") + +set(MSVC_2010 "_MSC_VER >= 1600") +set(_cmake_feature_test_cxx_auto_type "${MSVC_2010}") +set(_cmake_feature_test_cxx_decltype "${MSVC_2010}") +set(_cmake_feature_test_cxx_extended_friend_declarations "${MSVC_2010}") +set(_cmake_feature_test_cxx_extern_templates "${MSVC_2010}") +set(_cmake_feature_test_cxx_lambdas "${MSVC_2010}") +set(_cmake_feature_test_cxx_local_type_template_args "${MSVC_2010}") +set(_cmake_feature_test_cxx_long_long_type "${MSVC_2010}") +set(_cmake_feature_test_cxx_nullptr "${MSVC_2010}") +set(_cmake_feature_test_cxx_override "${MSVC_2010}") +set(_cmake_feature_test_cxx_right_angle_brackets "${MSVC_2010}") +set(_cmake_feature_test_cxx_rvalue_references "${MSVC_2010}") +set(_cmake_feature_test_cxx_static_assert "${MSVC_2010}") +set(_cmake_feature_test_cxx_template_template_parameters "${MSVC_2010}") +set(_cmake_feature_test_cxx_trailing_return_types "${MSVC_2010}") +set(_cmake_feature_test_cxx_variadic_macros "${MSVC_2010}") + +# Currently unsupported: +# set(_cmake_feature_test_cxx_constexpr ) +# set(_cmake_feature_test_cxx_relaxed_constexpr ) +# set(_cmake_feature_test_cxx_attributes ) +# set(_cmake_feature_test_cxx_attribute_deprecated ) +# 'NSDMIs for aggregates' +# set(_cmake_feature_test_cxx_aggregate_default_initializers ) +# set(_cmake_feature_test_cxx_variable_templates ) + +# In theory decltype incomplete return types was added in 2012 +# but without support for decltype_auto and return type deduction this +# feature is unusable. This remains so as of VS 2015 Preview. +# set(_cmake_feature_test_cxx_decltype_incomplete_return_types ) + +# Unset all the variables that we don't need exposed. +# _cmake_oldestSupported is required by WriteCompilerDetectionHeader +set(MSVC_2015) +set(MSVC_2013_v30723) +set(MSVC_2013) +set(MSVC_2012) +set(MSVC_2010) diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake new file mode 100644 index 0000000..82ce069 --- /dev/null +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -0,0 +1,9 @@ + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) + # MSVC has no specific language level or flags to change it. + set(CMAKE_CXX_STANDARD_DEFAULT "") +endif() + +macro(cmake_record_cxx_compile_features) + record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) +endmacro() diff --git a/Modules/Compiler/MSVC-DetermineCompiler.cmake b/Modules/Compiler/MSVC-DetermineCompiler.cmake new file mode 100644 index 0000000..313de89 --- /dev/null +++ b/Modules/Compiler/MSVC-DetermineCompiler.cmake @@ -0,0 +1,19 @@ + +set(_compiler_id_pp_test "defined(_MSC_VER)") + +set(_compiler_id_version_compute " + /* _MSC_VER = VVRR */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_MSC_VER % 100) +# if defined(_MSC_FULL_VER) +# if _MSC_VER >= 1400 + /* _MSC_FULL_VER = VVRRPPPPP */ +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_MSC_FULL_VER % 100000) +# else + /* _MSC_FULL_VER = VVRRPPPP */ +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_MSC_FULL_VER % 10000) +# endif +# endif +# if defined(_MSC_BUILD) +# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(_MSC_BUILD) +# endif") diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake new file mode 100644 index 0000000..18f141e --- /dev/null +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -0,0 +1,35 @@ +# Help CMAKE_PARSE_IMPLICIT_LINK_INFO detect NAG Fortran object files. +if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED) + message(STATUS "Detecting NAG Fortran directory") + # Run with -dryrun to see sample "link" line. + execute_process( + COMMAND ${CMAKE_Fortran_COMPILER} dummy.o -dryrun + OUTPUT_VARIABLE _dryrun + ERROR_VARIABLE _dryrun + ) + # Match an object file. + string(REGEX MATCH "/[^ ]*/[^ /][^ /]*\\.o" _nag_obj "${_dryrun}") + if(_nag_obj) + # Parse object directory and convert to a regex. + string(REGEX REPLACE "/[^/]*$" "" _nag_dir "${_nag_obj}") + string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" _nag_regex "${_nag_dir}") + set(CMAKE_Fortran_IMPLICIT_OBJECT_REGEX "^${_nag_regex}/") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Detecting NAG Fortran directory with -dryrun found\n" + " object: ${_nag_obj}\n" + " directory: ${_nag_dir}\n" + " regex: ${CMAKE_Fortran_IMPLICIT_OBJECT_REGEX}\n" + "from output:\n${_dryrun}\n\n") + message(STATUS "Detecting NAG Fortran directory - ${_nag_dir}") + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Detecting NAG Fortran directory with -dryrun failed:\n${_dryrun}\n\n") + message(STATUS "Detecting NAG Fortran directory - failed") + endif() +endif() + +set(CMAKE_Fortran_MODDIR_FLAG "-mdir ") +set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-PIC") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") +set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-PIC") diff --git a/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake b/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake new file mode 100644 index 0000000..2ed116c --- /dev/null +++ b/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake @@ -0,0 +1,10 @@ + +set(_compiler_id_pp_test "defined(__WATCOMC__)") + +set(_compiler_id_version_compute " + /* __WATCOMC__ = VVRP + 1100 */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__WATCOMC__ - 1100) / 100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__WATCOMC__ % 10) +# endif") diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake new file mode 100644 index 0000000..da88c01 --- /dev/null +++ b/Modules/Compiler/PGI-C.cmake @@ -0,0 +1,4 @@ +include(Compiler/PGI) +__compiler_pgi(C) +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") diff --git a/Modules/Compiler/PGI-CXX.cmake b/Modules/Compiler/PGI-CXX.cmake new file mode 100644 index 0000000..97c9555 --- /dev/null +++ b/Modules/Compiler/PGI-CXX.cmake @@ -0,0 +1,4 @@ +include(Compiler/PGI) +__compiler_pgi(CXX) +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") diff --git a/Modules/Compiler/PGI-DetermineCompiler.cmake b/Modules/Compiler/PGI-DetermineCompiler.cmake new file mode 100644 index 0000000..8d3dc9c --- /dev/null +++ b/Modules/Compiler/PGI-DetermineCompiler.cmake @@ -0,0 +1,9 @@ + +set(_compiler_id_pp_test "defined(__PGI)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__PGIC__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__PGIC_PATCHLEVEL__) +# endif") diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake new file mode 100644 index 0000000..2866254 --- /dev/null +++ b/Modules/Compiler/PGI-Fortran.cmake @@ -0,0 +1,10 @@ +include(Compiler/PGI) +__compiler_pgi(Fortran) + +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-Mnofreeform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-Mfreeform") + +set(CMAKE_Fortran_FLAGS_INIT "${CMAKE_Fortran_FLAGS_INIT} -Mpreprocess -Kieee") +set(CMAKE_Fortran_FLAGS_DEBUG_INIT "${CMAKE_Fortran_FLAGS_DEBUG_INIT} -Mbounds") + +set(CMAKE_Fortran_MODDIR_FLAG "-module ") diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake new file mode 100644 index 0000000..162e3c9 --- /dev/null +++ b/Modules/Compiler/PGI.cmake @@ -0,0 +1,35 @@ + +#============================================================================= +# Copyright 2002-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_PGI) + return() +endif() +set(__COMPILER_PGI 1) + +macro(__compiler_pgi lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + + # Initial configuration flags. + set(CMAKE_${lang}_FLAGS_INIT "") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g -O0") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O2 -s") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-fast -O3 -Mipa=fast") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -gopt") + + # Preprocessing and assembly rules. + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") +endmacro() diff --git a/Modules/Compiler/PathScale-C.cmake b/Modules/Compiler/PathScale-C.cmake new file mode 100644 index 0000000..9db54af --- /dev/null +++ b/Modules/Compiler/PathScale-C.cmake @@ -0,0 +1,4 @@ +include(Compiler/PathScale) +__compiler_pathscale(C) +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") diff --git a/Modules/Compiler/PathScale-CXX.cmake b/Modules/Compiler/PathScale-CXX.cmake new file mode 100644 index 0000000..4dd7660 --- /dev/null +++ b/Modules/Compiler/PathScale-CXX.cmake @@ -0,0 +1,4 @@ +include(Compiler/PathScale) +__compiler_pathscale(CXX) +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") diff --git a/Modules/Compiler/PathScale-DetermineCompiler.cmake b/Modules/Compiler/PathScale-DetermineCompiler.cmake new file mode 100644 index 0000000..4eb81de --- /dev/null +++ b/Modules/Compiler/PathScale-DetermineCompiler.cmake @@ -0,0 +1,9 @@ + +set(_compiler_id_pp_test "defined(__PATHCC__)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__PATHCC__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__PATHCC_MINOR__) +# if defined(__PATHCC_PATCHLEVEL__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__PATHCC_PATCHLEVEL__) +# endif") diff --git a/Modules/Compiler/PathScale-Fortran.cmake b/Modules/Compiler/PathScale-Fortran.cmake new file mode 100644 index 0000000..d903621 --- /dev/null +++ b/Modules/Compiler/PathScale-Fortran.cmake @@ -0,0 +1,6 @@ +include(Compiler/PathScale) +__compiler_pathscale(Fortran) + +set(CMAKE_Fortran_MODDIR_FLAG "-module ") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixedform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-freeform") diff --git a/Modules/Compiler/PathScale.cmake b/Modules/Compiler/PathScale.cmake new file mode 100644 index 0000000..107f779 --- /dev/null +++ b/Modules/Compiler/PathScale.cmake @@ -0,0 +1,31 @@ + +#============================================================================= +# Copyright 2002-2010 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_PATHSCALE) + return() +endif() +set(__COMPILER_PATHSCALE 1) + +macro(__compiler_pathscale lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + + # Initial configuration flags. + set(CMAKE_${lang}_FLAGS_INIT "") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g -O0") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-Os") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O3") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g -O2") +endmacro() diff --git a/Modules/Compiler/QCC-C.cmake b/Modules/Compiler/QCC-C.cmake new file mode 100644 index 0000000..ae4a2f4 --- /dev/null +++ b/Modules/Compiler/QCC-C.cmake @@ -0,0 +1,2 @@ +include(Compiler/QCC) +__compiler_qcc(C) diff --git a/Modules/Compiler/QCC-CXX.cmake b/Modules/Compiler/QCC-CXX.cmake new file mode 100644 index 0000000..a676bbe --- /dev/null +++ b/Modules/Compiler/QCC-CXX.cmake @@ -0,0 +1,12 @@ +include(Compiler/QCC) +__compiler_qcc(CXX) + +# If the toolchain uses qcc for CMAKE_CXX_COMPILER instead of QCC, the +# default for the driver is not c++. +set(CMAKE_CXX_COMPILE_OBJECT + "<CMAKE_CXX_COMPILER> -lang-c++ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>") + +set(CMAKE_CXX_LINK_EXECUTABLE + "<CMAKE_CXX_COMPILER> -lang-c++ <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + +set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake new file mode 100644 index 0000000..76477e4 --- /dev/null +++ b/Modules/Compiler/QCC.cmake @@ -0,0 +1,24 @@ + +#============================================================================= +# Copyright 2002-2014 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) +include(Compiler/GNU) + +macro(__compiler_qcc lang) + __compiler_gnu(${lang}) + + # http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V") + + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,") + set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MMD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>") +endmacro() diff --git a/Modules/Compiler/SCO-C.cmake b/Modules/Compiler/SCO-C.cmake new file mode 100644 index 0000000..6e762cc --- /dev/null +++ b/Modules/Compiler/SCO-C.cmake @@ -0,0 +1,2 @@ +include(Compiler/SCO) +__compiler_sco(C) diff --git a/Modules/Compiler/SCO-CXX.cmake b/Modules/Compiler/SCO-CXX.cmake new file mode 100644 index 0000000..5b713a0 --- /dev/null +++ b/Modules/Compiler/SCO-CXX.cmake @@ -0,0 +1,2 @@ +include(Compiler/SCO) +__compiler_sco(CXX) diff --git a/Modules/Compiler/SCO-DetermineCompiler.cmake b/Modules/Compiler/SCO-DetermineCompiler.cmake new file mode 100644 index 0000000..a44b22b --- /dev/null +++ b/Modules/Compiler/SCO-DetermineCompiler.cmake @@ -0,0 +1,2 @@ + +set(_compiler_id_pp_test "defined(__SCO_VERSION__)") diff --git a/Modules/Compiler/SCO.cmake b/Modules/Compiler/SCO.cmake new file mode 100644 index 0000000..f673c8f --- /dev/null +++ b/Modules/Compiler/SCO.cmake @@ -0,0 +1,28 @@ + +#============================================================================= +# Copyright 2002-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_SCO) + return() +endif() +set(__COMPILER_SCO 1) + +macro(__compiler_sco lang) + # Feature flags. + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC -Kpic) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE -Kpie) + set(CMAKE_${lang}_COMPILE_OPTIONS_DLL -belf) + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-Kpic -belf") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-belf -Wl,-Bexport") +endmacro() diff --git a/Modules/Compiler/SDCC-C-DetermineCompiler.cmake b/Modules/Compiler/SDCC-C-DetermineCompiler.cmake new file mode 100644 index 0000000..1d7dd78 --- /dev/null +++ b/Modules/Compiler/SDCC-C-DetermineCompiler.cmake @@ -0,0 +1,10 @@ + +# sdcc, the small devices C compiler for embedded systems, +# http://sdcc.sourceforge.net */ +set(_compiler_id_pp_test "defined(SDCC)") + +set(_compiler_id_version_compute " + /* SDCC = VRP */ +# define COMPILER_VERSION_MAJOR @MACRO_DEC@(SDCC/100) +# define COMPILER_VERSION_MINOR @MACRO_DEC@(SDCC/10 % 10) +# define COMPILER_VERSION_PATCH @MACRO_DEC@(SDCC % 10)") diff --git a/Modules/Compiler/SunPro-ASM.cmake b/Modules/Compiler/SunPro-ASM.cmake new file mode 100644 index 0000000..2fa8b99 --- /dev/null +++ b/Modules/Compiler/SunPro-ASM.cmake @@ -0,0 +1,24 @@ +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) + +set(CMAKE_ASM_VERBOSE_FLAG "-#") + +set(CMAKE_SHARED_LIBRARY_ASM_FLAGS "-KPIC") +set(CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS "-G") +set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG "-R") +set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG_SEP ":") +set(CMAKE_SHARED_LIBRARY_SONAME_ASM_FLAG "-h") + +set(CMAKE_ASM_FLAGS_INIT "") +set(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") +set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") +set(CMAKE_ASM_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") +set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") + +# Initialize ASM link type selection flags. These flags are used when +# building a shared library, shared module, or executable that links +# to other libraries to select whether to use the static or shared +# versions of the libraries. +foreach(type SHARED_LIBRARY SHARED_MODULE EXE) + set(CMAKE_${type}_LINK_STATIC_ASM_FLAGS "-Bstatic") + set(CMAKE_${type}_LINK_DYNAMIC_ASM_FLAGS "-Bdynamic") +endforeach() diff --git a/Modules/Compiler/SunPro-C-DetermineCompiler.cmake b/Modules/Compiler/SunPro-C-DetermineCompiler.cmake new file mode 100644 index 0000000..e9d7457 --- /dev/null +++ b/Modules/Compiler/SunPro-C-DetermineCompiler.cmake @@ -0,0 +1,15 @@ + +set(_compiler_id_pp_test "defined(__SUNPRO_C)") + +set(_compiler_id_version_compute " +# if __SUNPRO_C >= 0x5100 + /* __SUNPRO_C = 0xVRRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__SUNPRO_C>>12) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__SUNPRO_C>>4 & 0xFF) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__SUNPRO_C & 0xF) +# else + /* __SUNPRO_CC = 0xVRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__SUNPRO_C>>8) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__SUNPRO_C>>4 & 0xF) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__SUNPRO_C & 0xF) +# endif") diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake new file mode 100644 index 0000000..92252cb --- /dev/null +++ b/Modules/Compiler/SunPro-C.cmake @@ -0,0 +1,26 @@ +set(CMAKE_C_VERBOSE_FLAG "-#") + +set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC) +set(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC") +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G") +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R") +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-h") + +set(CMAKE_C_FLAGS_INIT "") +set(CMAKE_C_FLAGS_DEBUG_INIT "-g") +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") + +# Initialize C link type selection flags. These flags are used when +# building a shared library, shared module, or executable that links +# to other libraries to select whether to use the static or shared +# versions of the libraries. +foreach(type SHARED_LIBRARY SHARED_MODULE EXE) + set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Bstatic") + set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Bdynamic") +endforeach() + +set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") +set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake b/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..5c23a95 --- /dev/null +++ b/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake @@ -0,0 +1,15 @@ + +set(_compiler_id_pp_test "defined(__SUNPRO_CC)") + +set(_compiler_id_version_compute " +# if __SUNPRO_CC >= 0x5100 + /* __SUNPRO_CC = 0xVRRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__SUNPRO_CC>>12) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__SUNPRO_CC>>4 & 0xFF) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__SUNPRO_CC & 0xF) +# else + /* __SUNPRO_CC = 0xVRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_HEX@(__SUNPRO_CC>>8) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_HEX@(__SUNPRO_CC>>4 & 0xF) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_HEX@(__SUNPRO_CC & 0xF) +# endif") diff --git a/Modules/Compiler/SunPro-CXX-FeatureTests.cmake b/Modules/Compiler/SunPro-CXX-FeatureTests.cmake new file mode 100644 index 0000000..8e97e1d --- /dev/null +++ b/Modules/Compiler/SunPro-CXX-FeatureTests.cmake @@ -0,0 +1,52 @@ + +# Based on GNU 4.8.2 +# http://docs.oracle.com/cd/E37069_01/html/E37071/gncix.html +# Reference: http://gcc.gnu.org/projects/cxx0x.html + +set(_cmake_oldestSupported "__SUNPRO_CC >= 0x5130") + +set(SolarisStudio124_CXX11 "(__SUNPRO_CC >= 0x5130) && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_alignas "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_alignof "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_attributes "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_inheriting_constructors "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_thread_local "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_alias_templates "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_delegating_constructors "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_extended_friend_declarations "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_final "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_noexcept "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_nonstatic_member_init "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_override "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_constexpr "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_defaulted_move_initializers "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_enum_forward_declarations "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_nullptr "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_range_for "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_unrestricted_unions "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_explicit_conversions "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_lambdas "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_local_type_template_args "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_raw_string_literals "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_auto_type "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_defaulted_functions "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_deleted_functions "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_generalized_initializers "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_inline_namespaces "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_sizeof_member "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_strong_enums "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_trailing_return_types "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_unicode_literals "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_uniform_initialization "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_variadic_templates "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_decltype "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_default_function_template_args "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_long_long_type "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_right_angle_brackets "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_rvalue_references "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_static_assert "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_extern_templates "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_func_identifier "${SolarisStudio124_CXX11}") +set(_cmake_feature_test_cxx_variadic_macros "${SolarisStudio124_CXX11}") + +set(_cmake_feature_test_cxx_template_template_parameters "${_cmake_oldestSupported} && __cplusplus") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake new file mode 100644 index 0000000..022b4d4 --- /dev/null +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -0,0 +1,55 @@ +set(CMAKE_CXX_VERBOSE_FLAG "-v") + +set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC) +set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC") +set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G") +set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R") +set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ":") +set(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-h") + +set(CMAKE_CXX_FLAGS_INIT "") +set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") + +# Initialize C link type selection flags. These flags are used when +# building a shared library, shared module, or executable that links +# to other libraries to select whether to use the static or shared +# versions of the libraries. +foreach(type SHARED_LIBRARY SHARED_MODULE EXE) + set(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Bstatic") + set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Bdynamic") +endforeach() + +set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") +set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") + +# Create archives with "CC -xar" in case user adds "-instances=extern" +# so that template instantiations are available to archive members. +set(CMAKE_CXX_CREATE_STATIC_LIBRARY + "<CMAKE_CXX_COMPILER> -xar -o <TARGET> <OBJECTS> " + "<CMAKE_RANLIB> <TARGET> ") + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") +endif() + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + set(CMAKE_CXX_STANDARD_DEFAULT 98) +endif() + +macro(cmake_record_cxx_compile_features) + macro(_get_solaris_studio_features std_version list) + record_compiler_features(CXX "${std_version}" ${list}) + endmacro() + + set(_result 0) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + _get_solaris_studio_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + if (_result EQUAL 0) + _get_solaris_studio_features("" CMAKE_CXX98_COMPILE_FEATURES) + endif() + endif() +endmacro() diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake new file mode 100644 index 0000000..196aae4 --- /dev/null +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -0,0 +1,22 @@ +set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") + +set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-KPIC") +set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC") +set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G") +set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-R") +set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ":") +set(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-h") +set(CMAKE_EXECUTABLE_RUNTIME_Fortran_FLAG "-R") + +set(CMAKE_Fortran_FLAGS_INIT "") +set(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") +set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") +set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") +set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-g -xO2 -DNDEBUG") +set(CMAKE_Fortran_MODDIR_FLAG "-moddir=") +set(CMAKE_Fortran_MODPATH_FLAG "-M") + +set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -F <SOURCE> -o <PREPROCESSED_SOURCE>") +set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/TI-ASM.cmake b/Modules/Compiler/TI-ASM.cmake new file mode 100644 index 0000000..e097626 --- /dev/null +++ b/Modules/Compiler/TI-ASM.cmake @@ -0,0 +1,8 @@ +set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") +set(CMAKE_LINK_LIBRARY_FLAG "--library=") +set(CMAKE_INCLUDE_FLAG_ASM "--include_path=") + +set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --compile_only --asm_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<OBJECT>") +set(CMAKE_ASM_LINK_EXECUTABLE "<CMAKE_ASM_COMPILER> <OBJECTS> --run_linker --output_file=<TARGET> <CMAKE_ASM_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>") + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS asm;s;abs) diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake new file mode 100644 index 0000000..b580994 --- /dev/null +++ b/Modules/Compiler/TI-C.cmake @@ -0,0 +1,10 @@ +set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") +set(CMAKE_LINK_LIBRARY_FLAG "--library=") +set(CMAKE_INCLUDE_FLAG_C "--include_path=") + +set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> --compile_only --skip_assembler --c_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>") +set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> --preproc_only --c_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>") + +set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> --compile_only --c_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<OBJECT>") +set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -r <TARGET> <OBJECTS>") +set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET>.map <CMAKE_C_LINK_FLAGS> <LINK_LIBRARIES> <LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Compiler/TI-CXX.cmake b/Modules/Compiler/TI-CXX.cmake new file mode 100644 index 0000000..8cf5ac3 --- /dev/null +++ b/Modules/Compiler/TI-CXX.cmake @@ -0,0 +1,10 @@ +set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") +set(CMAKE_LINK_LIBRARY_FLAG "--library=") +set(CMAKE_INCLUDE_FLAG_CXX "--include_path=") + +set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> --compile_only --skip_assembler --cpp_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>") +set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> --preproc_only --cpp_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>") + +set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> --compile_only --cpp_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<OBJECT>") +set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -r <TARGET> <OBJECTS>") +set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET>.map <CMAKE_CXX_LINK_FLAGS> <LINK_LIBRARIES> <LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Compiler/TI-DetermineCompiler.cmake b/Modules/Compiler/TI-DetermineCompiler.cmake new file mode 100644 index 0000000..19aa9e3 --- /dev/null +++ b/Modules/Compiler/TI-DetermineCompiler.cmake @@ -0,0 +1,8 @@ + +set(_compiler_id_pp_test "defined(__TI_COMPILER_VERSION__)") + +set(_compiler_id_version_compute " + /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__TI_COMPILER_VERSION__/1000000) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__TI_COMPILER_VERSION__/1000 % 1000) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__TI_COMPILER_VERSION__ % 1000)") diff --git a/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake b/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake new file mode 100644 index 0000000..8d6de7e --- /dev/null +++ b/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake @@ -0,0 +1,2 @@ + +set(_compiler_id_pp_test "defined(__TINYC__)") diff --git a/Modules/Compiler/TinyCC-C.cmake b/Modules/Compiler/TinyCC-C.cmake new file mode 100644 index 0000000..f7937ac --- /dev/null +++ b/Modules/Compiler/TinyCC-C.cmake @@ -0,0 +1,8 @@ +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") + +# no optimization in tcc: +set (CMAKE_C_FLAGS_INIT "") +set (CMAKE_C_FLAGS_DEBUG_INIT "-g") +set (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") +set (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") +set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -DNDEBUG") diff --git a/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake b/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake new file mode 100644 index 0000000..97c2263 --- /dev/null +++ b/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake @@ -0,0 +1,4 @@ + +set(_compiler_id_pp_test "defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800") + +include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-C-DetermineVersionInternal.cmake") diff --git a/Modules/Compiler/VisualAge-C.cmake b/Modules/Compiler/VisualAge-C.cmake new file mode 100644 index 0000000..40b609e --- /dev/null +++ b/Modules/Compiler/VisualAge-C.cmake @@ -0,0 +1 @@ +include(Compiler/XL-C) diff --git a/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake b/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..cd53499 --- /dev/null +++ b/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake @@ -0,0 +1,4 @@ + +set(_compiler_id_pp_test "defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800") + +include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-CXX-DetermineVersionInternal.cmake") diff --git a/Modules/Compiler/VisualAge-CXX.cmake b/Modules/Compiler/VisualAge-CXX.cmake new file mode 100644 index 0000000..2509b43 --- /dev/null +++ b/Modules/Compiler/VisualAge-CXX.cmake @@ -0,0 +1 @@ +include(Compiler/XL-CXX) diff --git a/Modules/Compiler/VisualAge-Fortran.cmake b/Modules/Compiler/VisualAge-Fortran.cmake new file mode 100644 index 0000000..3ef3178 --- /dev/null +++ b/Modules/Compiler/VisualAge-Fortran.cmake @@ -0,0 +1 @@ +include(Compiler/XL-Fortran) diff --git a/Modules/Compiler/Watcom-DetermineCompiler.cmake b/Modules/Compiler/Watcom-DetermineCompiler.cmake new file mode 100644 index 0000000..153e350 --- /dev/null +++ b/Modules/Compiler/Watcom-DetermineCompiler.cmake @@ -0,0 +1,10 @@ + +set(_compiler_id_pp_test "defined(__WATCOMC__) && __WATCOMC__ < 1200") + +set(_compiler_id_version_compute " + /* __WATCOMC__ = VVRR */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__WATCOMC__ / 100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__WATCOMC__ % 10) +# endif") diff --git a/Modules/Compiler/XL-ASM.cmake b/Modules/Compiler/XL-ASM.cmake new file mode 100644 index 0000000..07507f9 --- /dev/null +++ b/Modules/Compiler/XL-ASM.cmake @@ -0,0 +1,13 @@ +set(CMAKE_ASM_VERBOSE_FLAG "-V") + +# -qthreaded = Ensures that all optimizations will be thread-safe +# -qalias=noansi = Turns off type-based aliasing completely (safer optimizer) +# -qhalt=e = Halt on error messages (rather than just severe errors) +set(CMAKE_ASM_FLAGS_INIT "-qthreaded -qalias=noansi -qhalt=e -qsourcetype=assembler") + +set(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") +set(CMAKE_ASM_FLAGS_RELEASE_INIT "-O -DNDEBUG") +set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-O -DNDEBUG") +set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-g -DNDEBUG") + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) diff --git a/Modules/Compiler/XL-C-DetermineCompiler.cmake b/Modules/Compiler/XL-C-DetermineCompiler.cmake new file mode 100644 index 0000000..3f4e05c --- /dev/null +++ b/Modules/Compiler/XL-C-DetermineCompiler.cmake @@ -0,0 +1,4 @@ + +set(_compiler_id_pp_test "defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800") + +include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-C-DetermineVersionInternal.cmake") diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake new file mode 100644 index 0000000..09a5529 --- /dev/null +++ b/Modules/Compiler/XL-C.cmake @@ -0,0 +1,9 @@ +include(Compiler/XL) +__compiler_xl(C) +set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") + +# -qthreaded = Ensures that all optimizations will be thread-safe +# -qalias=noansi = Turns off type-based aliasing completely (safer optimizer) +# -qhalt=e = Halt on error messages (rather than just severe errors) +set(CMAKE_C_FLAGS_INIT "-qthreaded -qalias=noansi -qhalt=e") diff --git a/Modules/Compiler/XL-CXX-DetermineCompiler.cmake b/Modules/Compiler/XL-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..dffa4bc --- /dev/null +++ b/Modules/Compiler/XL-CXX-DetermineCompiler.cmake @@ -0,0 +1,4 @@ + +set(_compiler_id_pp_test "defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800") + +include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-CXX-DetermineVersionInternal.cmake") diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake new file mode 100644 index 0000000..6c842cd --- /dev/null +++ b/Modules/Compiler/XL-CXX.cmake @@ -0,0 +1,11 @@ +include(Compiler/XL) +__compiler_xl(CXX) +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") + +# -qthreaded = Ensures that all optimizations will be thread-safe +# -qhalt=e = Halt on error messages (rather than just severe errors) +set(CMAKE_CXX_FLAGS_INIT "-qthreaded -qhalt=e") + +set(CMAKE_CXX_COMPILE_OBJECT + "<CMAKE_CXX_COMPILER> -+ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake new file mode 100644 index 0000000..ae9df4e --- /dev/null +++ b/Modules/Compiler/XL-Fortran.cmake @@ -0,0 +1,17 @@ +include(Compiler/XL) +__compiler_xl(Fortran) + +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=<right_margin>] +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm] + +set(CMAKE_Fortran_MODDIR_FLAG "-qmoddir=") + +set(CMAKE_Fortran_DEFINE_FLAG "-WF,-D") + +# -qthreaded = Ensures that all optimizations will be thread-safe +# -qhalt=e = Halt on error messages (rather than just severe errors) +set(CMAKE_Fortran_FLAGS_INIT "-qthreaded -qhalt=e") + +# xlf: 1501-214 (W) command option E reserved for future use - ignored +set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE) +set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE) diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake new file mode 100644 index 0000000..7bf5020 --- /dev/null +++ b/Modules/Compiler/XL.cmake @@ -0,0 +1,54 @@ + +#============================================================================= +# Copyright 2002-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_XL) + return() +endif() +set(__COMPILER_XL 1) + +# Find the CreateExportList program that comes with this toolchain. +find_program(CMAKE_XL_CreateExportList + NAMES CreateExportList + DOC "IBM XL CreateExportList tool" + ) + +macro(__compiler_xl lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-V") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic") + + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") + + # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones. + # If we found the tool, we'll use it to create exports, otherwise stick with the regular + # create shared library compile line. + if (CMAKE_XL_CreateExportList) + # The compiler front-end passes all object files, archive files, and shared + # library files named on the command line to CreateExportList to create a + # list of all symbols to be exported from the shared library. This causes + # all archive members to be copied into the shared library whether they are + # needed or not. Instead we run the tool ourselves to pass only the object + # files so that we export only the symbols actually provided by the sources. + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>" + "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" + ) + endif() +endmacro() diff --git a/Modules/Compiler/zOS-C-DetermineCompiler.cmake b/Modules/Compiler/zOS-C-DetermineCompiler.cmake new file mode 100644 index 0000000..daa3781 --- /dev/null +++ b/Modules/Compiler/zOS-C-DetermineCompiler.cmake @@ -0,0 +1,4 @@ + +set(_compiler_id_pp_test "defined(__IBMC__) && defined(__COMPILER_VER__)") + +include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-C-DetermineVersionInternal.cmake") diff --git a/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake b/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..a08ff57 --- /dev/null +++ b/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake @@ -0,0 +1,4 @@ + +set(_compiler_id_pp_test "defined(__IBMCPP__) && defined(__COMPILER_VER__)") + +include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-CXX-DetermineVersionInternal.cmake") |