summaryrefslogtreecommitdiffstats
path: root/CMakeScripts/Modules
diff options
context:
space:
mode:
authorBryce Harrington <bryce@bryceharrington.org>2016-02-27 09:25:50 +0000
committerbryce <bryce@bryceharrington.org>2016-02-27 09:25:50 +0000
commit53a4d10251bb079fa22ced4dcbb381f42f56ceb1 (patch)
tree364b09b8902cdeaa0fa6d41b40d4833b2a4f3dfe /CMakeScripts/Modules
parentinkview: Drop use of obsolete getopt (diff)
downloadinkscape-53a4d10251bb079fa22ced4dcbb381f42f56ceb1.tar.gz
inkscape-53a4d10251bb079fa22ced4dcbb381f42f56ceb1.zip
cmake: Add sigc++ support
Patch from rindolf Signed-off-by: Bryce Harrington <bryce@bryceharrington.org> (bzr r14669)
Diffstat (limited to 'CMakeScripts/Modules')
-rw-r--r--CMakeScripts/Modules/FindSigC++.cmake22
-rw-r--r--CMakeScripts/Modules/sigcpp_test.cpp15
2 files changed, 36 insertions, 1 deletions
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 <stddef.h>
+#include <string>
+#include <sigc++/signal.h>
+
+int main()
+{
+ return 0;
+}