Commit be429079 by Baruch Sterin

CMakeLists.txt: pass CXX flags from the Makefile

parent c0ba25a6
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.3.0)
include(CMakeParseArguments) include(CMakeParseArguments)
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
# filter out flags that are not appropriate for the compiler used # filter out flags that are not appropriate for the compiler being used
function(target_compile_options_filtered target visibility) function(target_compile_options_filtered target visibility)
foreach( flag ${ARGN} ) foreach( flag ${ARGN} )
if( flag MATCHES "^-D.*" ) if( flag MATCHES "^-D.*" )
target_compile_options( ${target} ${visibility} ${flag} ) target_compile_options( ${target} ${visibility} ${flag} )
else() else()
check_c_compiler_flag( ${flag} COMPILER_SUPPORTS__${flag} ) check_c_compiler_flag( ${flag} C_COMPILER_SUPPORTS__${flag} )
if( COMPILER_SUPPORTS__${flag} ) if( C_COMPILER_SUPPORTS__${flag} )
target_compile_options( ${target} ${visibility} ${flag} ) target_compile_options( ${target} ${visibility} $<$<COMPILE_LANGUAGE:C>:${flag}> )
endif()
check_cxx_compiler_flag( ${flag} CXX_COMPILER_SUPPORTS__${flag} )
if( CXX_COMPILER_SUPPORTS__${flag} )
target_compile_options( ${target} ${visibility} $<$<COMPILE_LANGUAGE:CXX>:${flag}> )
endif() endif()
endif() endif()
endforeach() endforeach()
...@@ -40,6 +46,8 @@ endfunction() ...@@ -40,6 +46,8 @@ endfunction()
extract_var(SEPARATOR_SRC ABC_SRC ${MAKE_OUTPUT}) extract_var(SEPARATOR_SRC ABC_SRC ${MAKE_OUTPUT})
extract_var(SEPARATOR_LIBS ABC_LIBS ${MAKE_OUTPUT}) extract_var(SEPARATOR_LIBS ABC_LIBS ${MAKE_OUTPUT})
extract_var(SEPARATOR_CFLAGS ABC_CFLAGS ${MAKE_OUTPUT}) extract_var(SEPARATOR_CFLAGS ABC_CFLAGS ${MAKE_OUTPUT})
extract_var(SEPARATOR_CXXFLAGS ABC_CXXFLAGS ${MAKE_OUTPUT})
add_executable(abc ${ABC_SRC}) add_executable(abc ${ABC_SRC})
......
...@@ -193,5 +193,6 @@ docs: ...@@ -193,5 +193,6 @@ docs:
cmake_info: cmake_info:
@echo SEPARATOR_CFLAGS $(CFLAGS) SEPARATOR_CFLAGS @echo SEPARATOR_CFLAGS $(CFLAGS) SEPARATOR_CFLAGS
@echo SEPARATOR_CXXFLAGS $(CXXFLAGS) SEPARATOR_CXXFLAGS
@echo SEPARATOR_LIBS $(LIBS) SEPARATOR_LIBS @echo SEPARATOR_LIBS $(LIBS) SEPARATOR_LIBS
@echo SEPARATOR_SRC $(SRC) SEPARATOR_SRC @echo SEPARATOR_SRC $(SRC) SEPARATOR_SRC
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment