From da460f9008f5a949f663e749455e15fb5959d803 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 22 Oct 2002 18:17:07 -0400 Subject: [PATCH] test for gnu compiler --- Modules/CMakeDetermineCCompiler.cmake | 12 ++++++++---- Modules/CMakeDetermineCXXCompiler.cmake | 9 +++++++++ Modules/CMakeTestGNU.c | 3 +++ Modules/Windows.cmake | 4 ++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 Modules/CMakeTestGNU.c create mode 100644 Modules/Windows.cmake diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index c1fc85c7a..1035f1bb4 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -4,8 +4,12 @@ FIND_PROGRAM(CMAKE_C_COMPILER NAMES $ENV{CC} gcc cc cl bcc PATHS /bin /usr/bin /usr/local/bin ) +# test to see if the c compiler is gnu +EXEC_PROGRAM(${CMAKE_C_COMPILER} ARGS -E ${CMAKE_ROOT}/Modules/CMakeTestGNU.c OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN) + +IF(NOT CMAKE_COMPILER_RETURN) + IF(${CMAKE_COMPILER_OUTPUT} MATCHES ".*THIS_IS_GNU.*" ) + SET(CMAKE_COMPILER_IS_GNUGCC 1) + ENDIF(${CMAKE_COMPILER_OUTPUT} MATCHES ".*THIS_IS_GNU.*" ) +ENDIF(NOT CMAKE_COMPILER_RETURN) -# to check for is gnu we need to compile this: -# #ifdef __GNUC__ -# yes; -# #endif diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 72ee90aed..5b09e8531 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -3,3 +3,12 @@ # loading this file to force a compiler. FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES $ENV{CXX} c++ g++ CC aCC cl bcc PATHS /bin /usr/bin /usr/local/bin ) + +# test to see if the cxx compiler is gnu +EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS -E ${CMAKE_ROOT}/Modules/CMakeTestGNU.c OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN) + +IF(NOT CMAKE_COMPILER_RETURN) + IF(${CMAKE_COMPILER_OUTPUT} MATCHES ".*THIS_IS_GNU.*" ) + SET(CMAKE_COMPILER_IS_GNUGXX 1) + ENDIF(${CMAKE_COMPILER_OUTPUT} MATCHES ".*THIS_IS_GNU.*" ) +ENDIF(NOT CMAKE_COMPILER_RETURN) diff --git a/Modules/CMakeTestGNU.c b/Modules/CMakeTestGNU.c new file mode 100644 index 000000000..1cd56244b --- /dev/null +++ b/Modules/CMakeTestGNU.c @@ -0,0 +1,3 @@ +#ifdef __GNUC__ +THIS_IS_GNU +#endif diff --git a/Modules/Windows.cmake b/Modules/Windows.cmake new file mode 100644 index 000000000..0c1fa6cc6 --- /dev/null +++ b/Modules/Windows.cmake @@ -0,0 +1,4 @@ +SET(CMAKE_SHARED_LIBRARY_CREATE_FLAGS "") +SET(CMAKE_DL_LIBS "" ) +SET(CMAKE_SHARED_LIBRARY_PREFIX "") +SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")