diff options
author | Stephen Kelly <steveire@gmail.com> | 2014-04-23 08:46:47 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-05-07 12:00:00 (GMT) |
commit | 36ed5894840f40f6859710d44be607c929e5d38c (patch) | |
tree | 9f597a5e579019f0aceb78cb3ed0b6003e3b33cd | |
parent | 9a083bce83cfa31192ad34ba504454f8087c4fce (diff) | |
download | CMake-36ed5894840f40f6859710d44be607c929e5d38c.zip CMake-36ed5894840f40f6859710d44be607c929e5d38c.tar.gz CMake-36ed5894840f40f6859710d44be607c929e5d38c.tar.bz2 |
CompilerId: Allow specifying the compiler-specific components to generate.
-rw-r--r-- | Modules/CMakeCompilerIdDetection.cmake | 20 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 5 |
2 files changed, 22 insertions, 3 deletions
diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index eee1337..5df525f 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -20,6 +20,8 @@ function(_readFile file) set(_compiler_id_pp_test_${CompilerId} ${_compiler_id_pp_test} PARENT_SCOPE) endfunction() +include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) + function(compiler_id_detection outvar lang) file(GLOB lang_files @@ -36,6 +38,12 @@ function(compiler_id_detection outvar lang) _readFile(${file}) endforeach() + set(options ID_STRING VERSION_STRINGS) + cmake_parse_arguments(CID "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if (CID_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unrecognized arguments: \"${CID_UNPARSED_ARGUMENTS}\"") + endif() + set(ordered_compilers # Order is relevant here. For example, compilers which pretend to be # GCC must appear before the actual GCC. @@ -65,14 +73,22 @@ function(compiler_id_detection outvar lang) MIPSpro) set(pp_if "#if") - set(CMAKE_${lang}_COMPILER_ID_CONTENT "/* Version number components: V=Version, R=Revision, P=Patch + if (CID_VERSION_STRINGS) + set(CMAKE_${lang}_COMPILER_ID_CONTENT "/* Version number components: V=Version, R=Revision, P=Patch Version date components: YYYY=Year, MM=Month, DD=Day */\n") + endif() foreach(Id ${ordered_compilers}) if (NOT _compiler_id_pp_test_${Id}) message(FATAL_ERROR "No preprocessor test for \"${Id}\"") endif() - set(id_content "${pp_if} ${_compiler_id_pp_test_${Id}}\n# define COMPILER_ID \"${Id}\"${_compiler_id_version_compute_${Id}}\n") + set(id_content "${pp_if} ${_compiler_id_pp_test_${Id}}\n") + if (CID_ID_STRING) + set(id_content "${id_content}# define COMPILER_ID \"${Id}\"") + endif() + if (CID_VERSION_STRINGS) + set(id_content "${id_content}${_compiler_id_version_compute_${Id}}\n") + endif() set(CMAKE_${lang}_COMPILER_ID_CONTENT "${CMAKE_${lang}_COMPILER_ID_CONTENT}\n${id_content}") set(pp_if "#elif") endforeach() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 94c2e50..712b748 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -105,7 +105,10 @@ function(CMAKE_DETERMINE_COMPILER_ID_WRITE lang src) find_file(src_in ${src}.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) file(READ ${src_in} ID_CONTENT_IN) - compiler_id_detection(CMAKE_${lang}_COMPILER_ID_CONTENT ${lang}) + compiler_id_detection(CMAKE_${lang}_COMPILER_ID_CONTENT ${lang} + ID_STRING + VERSION_STRINGS + ) unset(src_in CACHE) string(CONFIGURE "${ID_CONTENT_IN}" ID_CONTENT_OUT @ONLY) |