diff options
Diffstat (limited to 'Modules')
26 files changed, 413 insertions, 11 deletions
diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index e6b3ee3..044326c 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -84,6 +84,7 @@ function(compiler_id_detection outvar lang) ) list(APPEND ordered_compilers Clang + LCC GNU MSVC ADSP diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 15eab0f..f5298df 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -160,7 +160,7 @@ endif () # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" if (NOT _CMAKE_TOOLCHAIN_PREFIX) - if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|QCC") + if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|QCC|LCC") get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) if (COMPILER_BASENAME MATCHES "^(.+-)?(clang|g?cc)(-cl)?(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 72dc8d3..fd3d028 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -159,7 +159,7 @@ endif () if (NOT _CMAKE_TOOLCHAIN_PREFIX) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|QCC") + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|QCC|LCC") get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) if (COMPILER_BASENAME MATCHES "^(.+-)?(clang\\+\\+|[gc]\\+\\+|clang-cl)(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index c967ab7..aec86d9 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -148,7 +148,7 @@ macro(_cmake_find_compiler_path lang) endmacro() function(_cmake_find_compiler_sysroot lang) - if(CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") + if(CMAKE_${lang}_COMPILER_ID STREQUAL "GNU" OR CMAKE_${lang}_COMPILER_ID STREQUAL "LCC") execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -print-sysroot OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE _cmake_sysroot_run_out diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index fa283fe..6437be0 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -150,7 +150,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() endif() - if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") + if (COMPILER_QNXNTO AND (CMAKE_${lang}_COMPILER_ID STREQUAL "GNU" OR CMAKE_${lang}_COMPILER_ID STREQUAL "LCC")) execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" -V diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 6a8984b..33b8bf4 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -78,12 +78,13 @@ else() set(CMAKE_Fortran_COMPILER_LIST ftn ifort ifc ifx efc pgf95 pgfortran lf95 xlf95 fort - flang gfortran gfortran-4 g95 f90 pgf90 + flang lfortran gfortran gfortran-4 g95 f90 pgf90 frt pgf77 xlf g77 f77 nag ) endif() # Vendor-specific compiler names. + set(_Fortran_COMPILER_NAMES_LCC lfortran gfortran) set(_Fortran_COMPILER_NAMES_GNU gfortran gfortran-4 g95 g77) set(_Fortran_COMPILER_NAMES_Intel ifort ifc efc ifx) set(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77) diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake index f90301b..5d7d430 100644 --- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake +++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake @@ -88,7 +88,7 @@ set(ENV{LANG} C) # Now check for C, works for gcc and Intel compiler at least if (NOT CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS) - if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES "Intel" OR CMAKE_C_COMPILER_ID MATCHES Clang) + if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES "LCC" OR CMAKE_C_COMPILER_ID MATCHES "Intel" OR CMAKE_C_COMPILER_ID MATCHES Clang) _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c _dirs _defines) set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "C compiler system include directories") set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "C compiler system defined macros") @@ -99,7 +99,7 @@ endif () # And now the same for C++ if (NOT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS) - if ("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang) + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "LCC" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang) _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c++ _dirs _defines) set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "CXX compiler system include directories") set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "CXX compiler system defined macros") diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index d0e0e46..969c841 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -95,6 +95,13 @@ # endif #elif defined(__ABSOFT__) PRINT *, 'INFO:compiler[Absoft]' +#elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__)) + PRINT *, 'INFO:compiler[LCC]' +# define COMPILER_VERSION_MAJOR DEC(1) +# define COMPILER_VERSION_MINOR DEC(__LCC__ - 100) +# if defined(__LCC_MINOR__) +# define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__) +# endif #elif defined(__GNUC__) PRINT *, 'INFO:compiler[GNU]' # define COMPILER_VERSION_MAJOR DEC(__GNUC__) diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index a61f71b..6bdefde 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -58,6 +58,10 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj endif() separate_arguments(args NATIVE_COMMAND "${line}") list(GET args 0 cmd) + if("${cmd}" MATCHES "->") + # LCC has '-> ' in-front of the linker + list(GET args 1 cmd) + endif() else() #check to see if the link line is comma-separated instead of space separated string(REGEX REPLACE "," " " line "${line}") diff --git a/Modules/Compiler/LCC-C-DetermineCompiler.cmake b/Modules/Compiler/LCC-C-DetermineCompiler.cmake new file mode 100644 index 0000000..6c7a08f --- /dev/null +++ b/Modules/Compiler/LCC-C-DetermineCompiler.cmake @@ -0,0 +1,11 @@ + +set(_compiler_id_pp_test "defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__))") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(1) +# if defined(__LCC__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__LCC__- 100) +# endif +# if defined(__LCC_MINOR__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__LCC_MINOR__) +# endif") diff --git a/Modules/Compiler/LCC-C-FeatureTests.cmake b/Modules/Compiler/LCC-C-FeatureTests.cmake new file mode 100644 index 0000000..0ab5265 --- /dev/null +++ b/Modules/Compiler/LCC-C-FeatureTests.cmake @@ -0,0 +1,17 @@ + +set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 304") + +# 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 3.4 at least: +set(GNU34_C99 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 304 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") +set(_cmake_feature_test_c_restrict "${GNU34_C99}") +set(_cmake_feature_test_c_variadic_macros "${GNU34_C99}") + +set(GNU_C90 "${_cmake_oldestSupported}") +set(_cmake_feature_test_c_function_prototypes "${GNU_C90}") diff --git a/Modules/Compiler/LCC-C.cmake b/Modules/Compiler/LCC-C.cmake new file mode 100644 index 0000000..3dd6e68 --- /dev/null +++ b/Modules/Compiler/LCC-C.cmake @@ -0,0 +1,29 @@ +include(Compiler/LCC) +__compiler_lcc(C) + + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_C) + # dependencies are computed by the compiler itself + set(CMAKE_C_DEPFILE_FORMAT gcc) + set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) +endif() + +set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) + +set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") +set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") +set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") +set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") +set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") +set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") +set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") +set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") +set(CMAKE_C23_STANDARD_COMPILE_OPTION "-std=c2x") +set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-std=gnu2x") + +__compiler_check_default_language_standard(C 1.23 90 1.20 11 1.26 17) diff --git a/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake b/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..6c7a08f --- /dev/null +++ b/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake @@ -0,0 +1,11 @@ + +set(_compiler_id_pp_test "defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__))") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(1) +# if defined(__LCC__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__LCC__- 100) +# endif +# if defined(__LCC_MINOR__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__LCC_MINOR__) +# endif") diff --git a/Modules/Compiler/LCC-CXX-FeatureTests.cmake b/Modules/Compiler/LCC-CXX-FeatureTests.cmake new file mode 100644 index 0000000..45c5470 --- /dev/null +++ b/Modules/Compiler/LCC-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}") +# 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 features below are 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}") +set(_cmake_feature_test_cxx_lambda_init_captures "${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/LCC-CXX.cmake b/Modules/Compiler/LCC-CXX.cmake new file mode 100644 index 0000000..b3bdd3c --- /dev/null +++ b/Modules/Compiler/LCC-CXX.cmake @@ -0,0 +1,31 @@ +include(Compiler/LCC) +__compiler_lcc(CXX) + + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_CXX) + # dependencies are computed by the compiler itself + set(CMAKE_CXX_DEPFILE_FORMAT gcc) + set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) +endif() + +set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) + +set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") + +set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") +set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") +set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") +set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") +set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") +set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") +set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") +set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") +set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + +__compiler_check_default_language_standard(CXX 1.19 98 1.20 11 1.21 14 1.24 17 1.26 20) diff --git a/Modules/Compiler/LCC-FindBinUtils.cmake b/Modules/Compiler/LCC-FindBinUtils.cmake new file mode 100644 index 0000000..4dcdd53 --- /dev/null +++ b/Modules/Compiler/LCC-FindBinUtils.cmake @@ -0,0 +1,37 @@ +if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "") + message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set") +endif() + +# Ubuntu 16.04: +# * /usr/bin/gcc-ar-5 +# * /usr/bin/gcc-ranlib-5 +string(REGEX MATCH "^([0-9]+)" __version_x + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}") + +string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}") + +# Try to find tools in the same directory as GCC itself +get_filename_component(__gcc_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) + +# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ar.1.html +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_COMPILER_SUFFIX}" + HINTS ${__gcc_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH + DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler" +) +mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR) + +# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ranlib.1.html +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib${_CMAKE_COMPILER_SUFFIX}" + HINTS ${__gcc_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH + DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler" +) +mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB) diff --git a/Modules/Compiler/LCC-Fortran.cmake b/Modules/Compiler/LCC-Fortran.cmake new file mode 100644 index 0000000..8091b29 --- /dev/null +++ b/Modules/Compiler/LCC-Fortran.cmake @@ -0,0 +1,26 @@ +include(Compiler/LCC) +__compiler_lcc(Fortran) + +set(CMAKE_Fortran_SUBMODULE_SEP "@") +set(CMAKE_Fortran_SUBMODULE_EXT ".smod") + +set(CMAKE_Fortran_PREPROCESS_SOURCE + "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>") + +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") + +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp") +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp") + +set(CMAKE_Fortran_POSTPROCESS_FLAG "-fpreprocessed") + +# No -DNDEBUG for Fortran. +string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " -Os") +string(APPEND 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/LCC.cmake b/Modules/Compiler/LCC.cmake new file mode 100644 index 0000000..8353ab6 --- /dev/null +++ b/Modules/Compiler/LCC.cmake @@ -0,0 +1,95 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_LCC) + return() +endif() +set(__COMPILER_LCC 1) + +include(Compiler/CMakeCommonCompilerMacros) + +set(__pch_header_C "c-header") +set(__pch_header_CXX "c++-header") +set(__pch_header_OBJC "objective-c-header") +set(__pch_header_OBJCXX "objective-c++-header") + +macro(__compiler_lcc lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + # Support of PIE at link stage depends on various elements : platform, compiler, linker + # so to activate it, module CheckPIESupported must be used. + set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER YES) + set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie") + set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie") + set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "--sysroot=") + + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") + + # 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(CMAKE_${lang}_COMPILER_ID STREQUAL "LCC" AND _IN_TC AND NOT CMAKE_FORCE_DEPFILES) + else() + # 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} "-MD -MT <DEP_TARGET> -MF <DEP_FILE>") + endif() + + # Initial configuration flags. + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") + set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) + set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) + set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + set(__lto_flags -flto) + list(APPEND __lto_flags -fno-fat-lto-objects) + set(CMAKE_${lang}_COMPILE_OPTIONS_IPO ${__lto_flags}) + + set(CMAKE_${lang}_ARCHIVE_CREATE_IPO + "\"${CMAKE_${lang}_COMPILER_AR}\" cr <TARGET> <LINK_FLAGS> <OBJECTS>" + ) + + set(CMAKE_${lang}_ARCHIVE_APPEND_IPO + "\"${CMAKE_${lang}_COMPILER_AR}\" r <TARGET> <LINK_FLAGS> <OBJECTS>" + ) + + set(CMAKE_${lang}_ARCHIVE_FINISH_IPO + "\"${CMAKE_${lang}_COMPILER_RANLIB}\" <TARGET>" + ) + + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}") + if(CMAKE_${lang}_COMPILER_ARG1) + separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}") + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS}) + unset(_COMPILER_ARGS) + endif() + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + + if(NOT "x${lang}" STREQUAL "xFortran") + set(CMAKE_PCH_EXTENSION .gch) + if (NOT CMAKE_GENERATOR MATCHES "Xcode") + set(CMAKE_PCH_PROLOGUE "#pragma GCC system_header") + endif() + set(CMAKE_${lang}_COMPILE_OPTIONS_INVALID_PCH -Winvalid-pch) + set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -include <PCH_HEADER>) + set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -x ${__pch_header_${lang}} -include <PCH_HEADER>) + endif() +endmacro() diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 308138f..8ed7558 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -437,7 +437,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") set(BLAS_mkl_END_GROUP "") endif() # Switch to GNU Fortran support layer if needed (but not on Apple, where MKL does not provide it) - if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) + if(CMAKE_Fortran_COMPILER_LOADED AND (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" OR CMAKE_Fortran_COMPILER_ID STREQUAL "LCC") AND NOT APPLE) set(BLAS_mkl_INTFACE "gf") set(BLAS_mkl_THREADING "gnu") set(BLAS_mkl_OMP "gomp") diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 38faca2..b63f010 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -917,14 +917,14 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) if(NOT Boost_VERSION_STRING VERSION_LESS 1.69.0) # From GCC 5 and clang 4, versioning changes and minor becomes patch. # For those compilers, patch is exclude from compiler tag in Boost 1.69+ library naming. - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 4) + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 4) OR CMAKE_CXX_COMPILER_ID STREQUAL "LCC") set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 3) set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}") endif() endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "LCC") if(Boost_VERSION_STRING VERSION_LESS 1.34) set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 else() diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index e335355..020af5a 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -873,7 +873,7 @@ if( NOT HDF5_FOUND ) # Add library-based search paths for Fortran modules. if (NOT _hdf5_main_library STREQUAL "") # gfortran module directory - if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" OR CMAKE_Fortran_COMPILER_ID STREQUAL "LCC") get_filename_component(_hdf5_library_dir "${_hdf5_main_library}" DIRECTORY) list(APPEND _hdf5_inc_extra_paths "${_hdf5_library_dir}") unset(_hdf5_library_dir) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 929a809..ecfb7f9 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -102,6 +102,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG) unset(OpenMP_FLAG_CANDIDATES) set(OMP_FLAG_GNU "-fopenmp") + set(OMP_FLAG_LCC "-fopenmp") set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp" "-Xclang -fopenmp") set(OMP_FLAG_AppleClang "-Xclang -fopenmp") set(OMP_FLAG_HP "+Oopenmp") diff --git a/Modules/Platform/Linux-LCC-C.cmake b/Modules/Platform/Linux-LCC-C.cmake new file mode 100644 index 0000000..b204c55 --- /dev/null +++ b/Modules/Platform/Linux-LCC-C.cmake @@ -0,0 +1,2 @@ +include(Platform/Linux-LCC) +__linux_compiler_lcc(C) diff --git a/Modules/Platform/Linux-LCC-CXX.cmake b/Modules/Platform/Linux-LCC-CXX.cmake new file mode 100644 index 0000000..cf2fa35 --- /dev/null +++ b/Modules/Platform/Linux-LCC-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/Linux-LCC) +__linux_compiler_lcc(CXX) diff --git a/Modules/Platform/Linux-LCC-Fortran.cmake b/Modules/Platform/Linux-LCC-Fortran.cmake new file mode 100644 index 0000000..d3a4cf4 --- /dev/null +++ b/Modules/Platform/Linux-LCC-Fortran.cmake @@ -0,0 +1,3 @@ +include(Platform/Linux-LCC) +__linux_compiler_lcc(Fortran) +set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-llfortran") diff --git a/Modules/Platform/Linux-LCC.cmake b/Modules/Platform/Linux-LCC.cmake new file mode 100644 index 0000000..a375461 --- /dev/null +++ b/Modules/Platform/Linux-LCC.cmake @@ -0,0 +1,15 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__LINUX_COMPILER_LCC) + return() +endif() +set(__LINUX_COMPILER_LCC 1) + +macro(__linux_compiler_lcc lang) + # We pass this for historical reasons. Projects may have + # executables that use dlopen but do not set ENABLE_EXPORTS. + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") +endmacro() |