diff options
author | Brad King <brad.king@kitware.com> | 2010-02-01 14:03:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-02-01 14:03:05 (GMT) |
commit | 3c2ecbe74eb0d01dc276b98b1307b2580b81adc6 (patch) | |
tree | c0d14b0e92bd71a7b54d47bf256f020f09c9ba32 /Tests | |
parent | 17e5e5fcb0d92a9a2a6e94be57499f92e90dd1ba (diff) | |
download | CMake-3c2ecbe74eb0d01dc276b98b1307b2580b81adc6.zip CMake-3c2ecbe74eb0d01dc276b98b1307b2580b81adc6.tar.gz CMake-3c2ecbe74eb0d01dc276b98b1307b2580b81adc6.tar.bz2 |
Add alternate per-vendor compiler id detection
At least one Fortran compiler does not provide a preprocessor symbol to
identify itself. Instead we try running unknown compilers with version
query flags known for each vendor and look for known output. Future
commits will add vendor-specific flags/output table entries.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeTests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CMakeTests/CompilerIdVendorTest.cmake.in | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 161ca44..6df026e 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -26,6 +26,7 @@ AddCMakeTest(If "") AddCMakeTest(String "") AddCMakeTest(Math "") AddCMakeTest(CMakeMinimumRequired "") +AddCMakeTest(CompilerIdVendor "") if(HAVE_ELF_H) AddCMakeTest(ELF "") diff --git a/Tests/CMakeTests/CompilerIdVendorTest.cmake.in b/Tests/CMakeTests/CompilerIdVendorTest.cmake.in new file mode 100644 index 0000000..68f6462 --- /dev/null +++ b/Tests/CMakeTests/CompilerIdVendorTest.cmake.in @@ -0,0 +1,31 @@ +# This is not supposed to be included by user code, but we need to +# test it. +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + +set(MY_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/CompilerIdVendor") +file(REMOVE_RECURSE ${MY_BINARY_DIR}) +file(MAKE_DIRECTORY ${MY_BINARY_DIR}) + +set(CMAKE_MyLang_COMPILER ${CMAKE_COMMAND}) +set(CMAKE_MyLang_COMPILER_ID_ARG1) +set(CMAKE_MyLang_COMPILER_ID_FLAGS_LIST) +set(CMAKE_MyLang_COMPILER_ID_DIR ${MY_BINARY_DIR}) + +file(WRITE "${MY_BINARY_DIR}/BogusVendor.cmake" "message(\"This is a BogusVendor compiler\")") +list(APPEND CMAKE_MyLang_COMPILER_ID_VENDORS BogusVendor) +set(CMAKE_MyLang_COMPILER_ID_VENDOR_FLAGS_BogusVendor -P BogusVendor.cmake) +set(CMAKE_MyLang_COMPILER_ID_VENDOR_REGEX_BogusVendor ThisDoesNotMatch_BogusVendor) + +file(WRITE "${MY_BINARY_DIR}/MyVendor.cmake" "message(\"This is a MyVendor compiler\")") +list(APPEND CMAKE_MyLang_COMPILER_ID_VENDORS MyVendor) +set(CMAKE_MyLang_COMPILER_ID_VENDOR_FLAGS_MyVendor -P MyVendor.cmake) +set(CMAKE_MyLang_COMPILER_ID_VENDOR_REGEX_MyVendor MyVendor) + +set(CMAKE_BINARY_DIR ${MY_BINARY_DIR}) +cmake_determine_compiler_id_vendor(MyLang) + +if("${CMAKE_MyLang_COMPILER_ID}" STREQUAL "MyVendor") + message(STATUS "Found MyVendor compiler id!") +else() + message(FATAL_ERROR "Did not find MyVendor compiler id: [${CMAKE_MyLang_COMPILER_ID}]") +endif() |