commit c2e67a41ce4b3b281f6c8a805be5e821ce0aea0a
Author: Benjamin Piwowarski <[email protected]>
Date:   Sun Mar 9 08:29:27 2014 +0100

    Objective-C compililation support with cmake and C++11
    
    This fixes an issue whe compiling with C++11 flags on: The
    objective-C clang compiler produces an error. This patch waits
    avoid including specific C++ flags and uses LYX_CPP_SPECIFIC_FLAGS
    to store the confliciting flags (for the moment, just C++11).

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 023c3e1..fce4bed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -202,7 +202,8 @@ else()
 endif()
 
 
-set(LYX_GCC11_MODE)
+# Variable that hold the flags that should only be used with C++ files
+set(LYX_CXX_SPECIFIC_FLAGS)
 if(UNIX OR MINGW)
        execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion 
OUTPUT_VARIABLE GCC_VERSION)
        message(STATUS "Using GCC version ${GCC_VERSION}")
@@ -217,7 +218,7 @@ if(UNIX OR MINGW)
                if(NOT CXX11COMPILER_FOUND)
                        message(FATAL_ERROR "A C++11 compatible compiler is 
required.")
                endif()
-               set(LYX_GCC11_MODE "${CXX11_FLAG}")
+               set(LYX_CXX_SPECIFIC_FLAGS "${LYX_CXX_SPECIFIC_FLAGS} 
${CXX11_FLAG}")
        endif()
 else()
        if(MSVC10)
@@ -453,7 +454,7 @@ if(NOT MSVC)
        if(NOT LYX_QUIET)
                set(CMAKE_VERBOSE_MAKEFILE ON)
        endif()
-       set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}")
+       set(LYX_CXX_FLAGS "-Wall -Wunused-parameter")
        if(LYX_STDLIB_DEBUG)
                set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG 
-D_GLIBCXX_DEBUG_PEDANTIC")
        endif()
diff --git a/boost/CMakeLists.txt b/boost/CMakeLists.txt
index 6d7839a..8dcb275 100644
--- a/boost/CMakeLists.txt
+++ b/boost/CMakeLists.txt
@@ -4,5 +4,6 @@
 # Copyright (c) 2006-2011 Peter Kümmel, <[email protected]>
 #
 
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LYX_CXX_SPECIFIC_FLAGS}")
 add_subdirectory(libs) 
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5203d45..425cd9e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,11 +11,15 @@ include_directories(${TOP_SRC_DIR}/src)
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
 
+# support is the only directory containing objective-c files...
+add_subdirectory(support)
+# ...so we can add all the c++ specific flags after
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LYX_CXX_SPECIFIC_FLAGS}")
+
 add_subdirectory(frontends)
 add_subdirectory(graphics)
 add_subdirectory(insets)
 add_subdirectory(mathed)
-add_subdirectory(support)
 add_subdirectory(tex2lyx)
 if (UNIX)
        add_subdirectory(client)
diff --git a/src/support/CMakeLists.txt b/src/support/CMakeLists.txt
index ba0dfdc..04eb38e 100644
--- a/src/support/CMakeLists.txt
+++ b/src/support/CMakeLists.txt
@@ -22,6 +22,7 @@ file(GLOB support_mythes_headers 
${TOP_SRC_DIR}/src/support/mythes/*.hxx)
 file(GLOB support_linkback_sources ${TOP_SRC_DIR}/src/support/linkback/*.m*)
 file(GLOB support_linkback_headers ${TOP_SRC_DIR}/src/support/linkback/*.h)
 
+set_source_files_properties(${support_sources} ${support_mythes_sources} 
PROPERTIES COMPILE_FLAGS "${LYX_CXX_SPECIFIC_FLAGS}")
 list(REMOVE_ITEM support_sources
        ${TOP_SRC_DIR}/src/support/os_win32.cpp
        ${TOP_SRC_DIR}/src/support/os_unix.cpp
diff --git a/src/support/tests/CMakeLists.txt b/src/support/tests/CMakeLists.txt
index eac5aa7..7c4600f 100644
--- a/src/support/tests/CMakeLists.txt
+++ b/src/support/tests/CMakeLists.txt
@@ -6,6 +6,8 @@
 
 project(supporttest)
 
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LYX_CXX_SPECIFIC_FLAGS}")
+
 macro(sources _program)
        set(_tmplist)
        foreach(_tmp ${ARGN})

Reply via email to