diff --git a/CMakeLists.txt b/CMakeLists.txt index ad2e7ece27..d48f3319fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,12 +240,6 @@ if(APPLE) set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/usr") endif() - # Some of our code contains Objective C constructs. - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++") - # Avoid mistaking an object file for a source file on the link command line. - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none") - # Identify the target system: # Ask for 64-bit binary. set(TARGET_FLAGS "-arch x86_64") @@ -838,6 +832,15 @@ add_definitions(-std=gnu++0x) # but some dependencies require them (LLVM, libav). add_definitions(-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS) +# Do this at the last minute because try_compile ignores linker flags. Yay... +if(APPLE) + # Some of our code contains Objective C constructs. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++") + # Avoid mistaking an object file for a source file on the link command line. + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none") +endif() + add_subdirectory(Source) @@ -883,4 +886,3 @@ list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}") # CPack must be included after the CPACK_* variables are set in order for those # variables to take effect. Include(CPack) -