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).
This commit is contained in:
Benjamin Piwowarski 2014-03-09 08:29:27 +01:00 committed by Richard Heck
parent 06f12532d1
commit c2e67a41ce
5 changed files with 13 additions and 4 deletions

View File

@ -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()

View File

@ -4,5 +4,6 @@
# Copyright (c) 2006-2011 Peter Kümmel, <syntheticpp@gmx.net>
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LYX_CXX_SPECIFIC_FLAGS}")
add_subdirectory(libs)

View File

@ -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)

View File

@ -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

View File

@ -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})