From 53a4d10251bb079fa22ced4dcbb381f42f56ceb1 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Sat, 27 Feb 2016 01:25:50 -0800 Subject: cmake: Add sigc++ support Patch from rindolf Signed-off-by: Bryce Harrington (bzr r14669) --- CMakeScripts/Modules/FindSigC++.cmake | 22 +++++++++++++++++++++- CMakeScripts/Modules/sigcpp_test.cpp | 15 +++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 CMakeScripts/Modules/sigcpp_test.cpp (limited to 'CMakeScripts/Modules') diff --git a/CMakeScripts/Modules/FindSigC++.cmake b/CMakeScripts/Modules/FindSigC++.cmake index ed0abc545..8046410b5 100644 --- a/CMakeScripts/Modules/FindSigC++.cmake +++ b/CMakeScripts/Modules/FindSigC++.cmake @@ -13,7 +13,6 @@ # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # - if (SIGC++_LIBRARIES AND SIGC++_INCLUDE_DIRS) # in cache already set(SIGC++_FOUND TRUE) @@ -103,4 +102,25 @@ else (SIGC++_LIBRARIES AND SIGC++_INCLUDE_DIRS) endif (SIGC++_LIBRARIES AND SIGC++_INCLUDE_DIRS) +# Try to add -std=c++11 if needed - see: +# https://bugs.launchpad.net/inkscape/+bug/1488079 + +macro (sigcpp_compile extra_cppflags) + try_compile(SIGCPP_COMPILES_FINE "${CMAKE_BINARY_DIR}/sigcpp-bindir" + SOURCES "${CMAKE_SOURCE_DIR}/CMakeScripts/Modules/sigcpp_test.cpp" + COMPILE_DEFINITIONS ${_SIGC++_CFLAGS} ${extra_cppflags} + LINK_LIBRARIES ${SIGC++_LIBRARIES}) +endmacro() + + +sigcpp_compile("") +if (NOT "${SIGCPP_COMPILES_FINE}") + set (cppflag "-std=c++11") + sigcpp_compile("${cppflag}") + if ("${SIGCPP_COMPILES_FINE}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cppflag}") + else() + message(FATAL_ERROR "Could not compile against SIGC++") + endif() +endif() diff --git a/CMakeScripts/Modules/sigcpp_test.cpp b/CMakeScripts/Modules/sigcpp_test.cpp new file mode 100644 index 000000000..b4cf2c773 --- /dev/null +++ b/CMakeScripts/Modules/sigcpp_test.cpp @@ -0,0 +1,15 @@ +/* + * Building this using: + + g++ `pkg-config --cflags sigc++-2.0` sigcpp_test.cpp + + Results in an error. + * */ +#include +#include +#include + +int main() +{ + return 0; +} -- cgit v1.2.3