From 7dcdfec97fdefa90bded7868a638277d7c9903f1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 17 Jan 2015 14:08:47 +0100 Subject: WCDH: Find a language-specific DetermineCompiler.cmake if present. The SolarisStudio compiler module uses language specific files. --- Modules/WriteCompilerDetectionHeader.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index d61358f..0464e66 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -234,7 +234,11 @@ function(_load_compiler_variables CompilerId lang) foreach(feature ${ARGN}) set(_cmake_feature_test_${CompilerId}_${feature} ${_cmake_feature_test_${feature}} PARENT_SCOPE) endforeach() - include("${CMAKE_ROOT}/Modules/Compiler/${CompilerId}-DetermineCompiler.cmake" OPTIONAL) + include("${CMAKE_ROOT}/Modules/Compiler/${CompilerId}-${lang}-DetermineCompiler.cmake" OPTIONAL + RESULT_VARIABLE determinedCompiler) + if (NOT determinedCompiler) + include("${CMAKE_ROOT}/Modules/Compiler/${CompilerId}-DetermineCompiler.cmake" OPTIONAL) + endif() set(_compiler_id_version_compute_${CompilerId} ${_compiler_id_version_compute} PARENT_SCOPE) endfunction() -- cgit v0.12 From d84d6ed409c663573a02efa7d2692b6829d27c46 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 17 Jan 2015 14:10:26 +0100 Subject: WCDH: Allow compilers to specify features for one language but not the other. --- Modules/WriteCompilerDetectionHeader.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 0464e66..d9ab9fb 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -386,6 +386,13 @@ function(write_compiler_detection_header endif() foreach(_lang ${_langs}) + set(target_compilers) + foreach(compiler ${_WCD_COMPILERS}) + _load_compiler_variables(${compiler} ${_lang} ${${_lang}_features}) + if(_cmake_oldestSupported_${compiler}) + list(APPEND target_compilers ${compiler}) + endif() + endforeach() get_property(known_features GLOBAL PROPERTY CMAKE_${_lang}_KNOWN_FEATURES) foreach(feature ${${_lang}_features}) @@ -408,8 +415,7 @@ function(write_compiler_detection_header set(file_content "${file_content}${ID_CONTENT}\n") set(pp_if "if") - foreach(compiler ${_WCD_COMPILERS}) - _load_compiler_variables(${compiler} ${_lang} ${${_lang}_features}) + foreach(compiler ${target_compilers}) set(file_content "${file_content}\n# ${pp_if} ${prefix_arg}_COMPILER_IS_${compiler}\n") if(_WCD_OUTPUT_FILES_VAR) -- cgit v0.12 From 54156d723a3fde678ed7f884364ad0449d23ad2b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 17 Jan 2015 14:42:08 +0100 Subject: WCDH: Generate per-language files in multi-file mode. Otherwise we generate defines for C/CXX features unguarded by the presence of the __cplusplus macro and available to the wrong compiler. --- Modules/WriteCompilerDetectionHeader.cmake | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index d9ab9fb..a6ff475 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -419,12 +419,12 @@ function(write_compiler_detection_header set(file_content "${file_content}\n# ${pp_if} ${prefix_arg}_COMPILER_IS_${compiler}\n") if(_WCD_OUTPUT_FILES_VAR) - set(compile_file_name "${_WCD_OUTPUT_DIR}${prefix_arg}_COMPILER_INFO_${compiler}.h") + set(compile_file_name "${_WCD_OUTPUT_DIR}${prefix_arg}_COMPILER_INFO_${compiler}_${_lang}.h") set(file_content "${file_content}\n# include \"${compile_file_name}\"\n") endif() if(_WCD_OUTPUT_FILES_VAR) - set(compiler_file_content compiler_file_content_${compiler}) + set(compiler_file_content compiler_file_content_${compiler}_${_lang}) else() set(compiler_file_content file_content) endif() @@ -627,16 +627,20 @@ function(write_compiler_detection_header if(_WCD_OUTPUT_FILES_VAR) foreach(compiler ${_WCD_COMPILERS}) - set(CMAKE_CONFIGURABLE_FILE_CONTENT "${compiler_file_content_}") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "${CMAKE_CONFIGURABLE_FILE_CONTENT}${compiler_file_content_${compiler}}") - - set(compile_file_name "${_WCD_OUTPUT_DIR}${prefix_arg}_COMPILER_INFO_${compiler}.h") - set(full_path "${main_file_dir}/${compile_file_name}") - list(APPEND ${_WCD_OUTPUT_FILES_VAR} ${full_path}) - configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${full_path}" - @ONLY - ) + foreach(_lang ${_langs}) + if(compiler_file_content_${compiler}_${_lang}) + set(CMAKE_CONFIGURABLE_FILE_CONTENT "${compiler_file_content_}") + set(CMAKE_CONFIGURABLE_FILE_CONTENT "${CMAKE_CONFIGURABLE_FILE_CONTENT}${compiler_file_content_${compiler}_${_lang}}") + + set(compile_file_name "${_WCD_OUTPUT_DIR}${prefix_arg}_COMPILER_INFO_${compiler}_${_lang}.h") + set(full_path "${main_file_dir}/${compile_file_name}") + list(APPEND ${_WCD_OUTPUT_FILES_VAR} ${full_path}) + configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" + "${full_path}" + @ONLY + ) + endif() + endforeach() endforeach() set(${_WCD_OUTPUT_FILES_VAR} ${${_WCD_OUTPUT_FILES_VAR}} PARENT_SCOPE) endif() -- cgit v0.12 From 59e6e15cde911e182e471df5b99746e0e203ba43 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 17 Jan 2015 14:52:27 +0100 Subject: Help: Add notes for topic 'WriteCompilerDetectionHeader-multi-file-lang' --- Help/release/dev/WriteCompilerDetectionHeader-multi-file-lang.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Help/release/dev/WriteCompilerDetectionHeader-multi-file-lang.rst diff --git a/Help/release/dev/WriteCompilerDetectionHeader-multi-file-lang.rst b/Help/release/dev/WriteCompilerDetectionHeader-multi-file-lang.rst new file mode 100644 index 0000000..a8665da --- /dev/null +++ b/Help/release/dev/WriteCompilerDetectionHeader-multi-file-lang.rst @@ -0,0 +1,6 @@ +WriteCompilerDetectionHeader-multi-file +--------------------------------------- + +* The :module:`WriteCompilerDetectionHeader` module learned to create + multiple output files per compiler and per language, instead of creating + one large file. -- cgit v0.12