Fixed ObjectiveC cmake language to use the C compiler by default

This commit is contained in:
Snaipe 2015-10-07 17:42:12 +02:00
parent 02d46df360
commit 0ee9649446
4 changed files with 17 additions and 54 deletions

View file

@ -2,48 +2,8 @@
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
set(CMAKE_ObjectiveC_COMPILER_XCODE_TYPE sourcecode.m)
_cmake_find_compiler_path(ObjectiveC)
else()
if(NOT CMAKE_ObjectiveC_COMPILER)
set(CMAKE_ObjectiveC_COMPILER_INIT NOTFOUND)
if(NOT CMAKE_ObjectiveC_COMPILER_INIT)
set(CMAKE_ObjectiveC_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc clang)
endif()
_cmake_find_compiler(ObjectiveC)
else()
_cmake_find_compiler_path(ObjectiveC)
endif()
mark_as_advanced(CMAKE_ObjectiveC_COMPILER)
set(CMAKE_ObjectiveC_COMPILER_ID_TEST_FLAGS_FIRST)
set(CMAKE_ObjectiveC_COMPILER_ID_TEST_FLAGS "-c")
endif()
if(NOT CMAKE_ObjectiveC_COMPILER_ID_RUN)
set(CMAKE_ObjectiveC_COMPILER_ID_RUN 1)
# Try to identify the compiler.
set(CMAKE_ObjectiveC_COMPILER_ID)
set(CMAKE_ObjectiveC_PLATFORM_ID)
file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in
CMAKE_ObjectiveC_COMPILER_ID_PLATFORM_CONTENT)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
# we use the same compiler id source than C
CMAKE_DETERMINE_COMPILER_ID(ObjectiveC CFLAGS CMakeCCompilerId.c)
endif()
include(CMakeFindBinUtils)
set(CMAKE_ObjectiveC_COMPILER_ID ${CMAKE_C_COMPILER_ID})
set(CMAKE_ObjectiveC_COMPILER ${CMAKE_C_COMPILER})
# configure variables set in this file for fast reload later on
configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeObjectiveCCompiler.cmake.in

View file

@ -22,6 +22,8 @@ if(NOT CMAKE_ObjectiveC_COMPILER_WORKS)
"#ifdef __cplusplus\n"
"# error \"The CMAKE_ObjectiveC_COMPILER is set to an ObjectiveC++ compiler\"\n"
"#endif\n"
"@interface Foo\n"
"@end\n"
"int main(int argc, char* argv[])\n"
"{ (void)argv; return argc-1;}\n")
try_compile(CMAKE_ObjectiveC_COMPILER_WORKS ${CMAKE_BINARY_DIR}

View file

@ -1,15 +1,17 @@
if (NOT LANGUAGES)
set(LANGUAGES "")
option(LANG_CXX "Turn on C++ support" ON)
option(LANG_OBJC "Turn on Objective-C support" OFF)
if (LANG_CXX)
enable_language(CXX)
if (CMAKE_CXX_COMPILER_WORKS)
set(CXX_BRIDGE 1)
endif ()
endif ()
string(REPLACE "," ";" LANGUAGES "${LANGUAGES}")
foreach (LANG ${LANGUAGES})
enable_language(${LANG} OPTIONAL)
if (CMAKE_${LANG}_COMPILER_WORKS)
string(TOUPPER ${LANG} LANG_NAME)
set(${LANG_NAME}_BRIDGE 1)
if (LANG_OBJC)
enable_language(ObjectiveC)
if (CMAKE_ObjectiveC_COMPILER_WORKS)
set(OBJC_BRIDGE 1)
endif ()
endforeach ()
endif ()

View file

@ -49,7 +49,6 @@ if (NOT MSVC)
endif ()
endif ()
if (MSVC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
endif ()