diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2014-07-12 23:17:21 +1000 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2014-07-12 23:18:11 +1000 |
commit | bfd1320d9c77e84db29903489c8ea90317e55de2 (patch) | |
tree | e4f0dbadb65840992bd3890cf060c8dcca408836 | |
parent | 8971af22d03e08bcdbad566907248490f1f6f4e0 (diff) |
CMake : Detect and set COMPILER_IS_GCC.
-rw-r--r-- | CMake/compiler_is_gcc.c | 11 | ||||
-rw-r--r-- | CMake/libsndfile.cmake | 20 | ||||
-rw-r--r-- | CMakeLists.txt | 10 |
3 files changed, 38 insertions, 3 deletions
diff --git a/CMake/compiler_is_gcc.c b/CMake/compiler_is_gcc.c new file mode 100644 index 0000000..784c884 --- /dev/null +++ b/CMake/compiler_is_gcc.c @@ -0,0 +1,11 @@ +int main (void) +{ +#if __GNUC__ + #if __clang__ + This is clang +# endif +#else + This is not GCC. +#endif + return 0 ; +} diff --git a/CMake/libsndfile.cmake b/CMake/libsndfile.cmake new file mode 100644 index 0000000..7aa3361 --- /dev/null +++ b/CMake/libsndfile.cmake @@ -0,0 +1,20 @@ + +include (TestBigEndian) + +function (try_compile_c_result C_FILE RESULT_NAME RESULT_PASS RESULT_FAIL) + try_compile (COMPILE_RESULT + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/CMake/compiler_is_gcc.c + # OUTPUT_VARIABLE LOG2 + ) + + if (${COMPILE_RESULT}) + set (${RESULT_NAME} ${RESULT_PASS} PARENT_SCOPE) + else (${VARNAME}) + set (${RESULT_NAME} ${RESULT_FAIL} PARENT_SCOPE) + endif (${COMPILE_RESULT}) + + endfunction () + + +try_compile_c_result (CMake/compiler_is_gcc.c COMPILER_IS_GCC 1 0) diff --git a/CMakeLists.txt b/CMakeLists.txt index abb79df..fdda99b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,12 @@ # cmakelists.txt for libsndfile cmake_minimum_required (VERSION 2.8.12) +set (BASEPATH "${CMAKE_SOURCE_DIR}") + +project (libsndfile C) + +include (CMake/libsndfile.cmake) + if (MSVC) set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4996") add_definitions ("/wd4244 /wd4996") @@ -18,7 +24,7 @@ else (MSVC) set (HAVE_INTTYPES_H 1) set (HAVE_STDINT_H 1) set (SIZEOF_LONG 4) - set (COMPILER_IS_GCC 1) + set (COMPILER_IS_GCC ${COMPILER_IS_GCC}) set (OS_IS_WIN32 0) set (USE_WINDOWS_API 0) set (SIZEOF_INT64_T 8) @@ -42,7 +48,6 @@ else (MSVC) set (OSX_DARWIN_VERSION 0) endif (MSVC) -include (TestBigEndian) TEST_BIG_ENDIAN (BIGENDIAN) if (${BIGENDIAN}) set (WORDS_BIGENDIAN 1) @@ -56,7 +61,6 @@ endif (${BIGENDIAN}) #------------------------------------------------------------------------------- # Project definitions follow. -project (libsndfile C) configure_file (src/sndfile.h.in src/sndfile.h) configure_file (CMake/config.h.in src/config.h) |