summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2014-06-25 13:46:35 +0100
committerJosé Fonseca <jfonseca@vmware.com>2014-06-25 13:46:35 +0100
commitc56b9acc6abcae465b916f6ebafa3a282d1f36fc (patch)
treea4a0a04879c4b48f23eddc33fb58ba8396143dd7
parente11baf1cb0a60855c975374890c497e3e5bbe4ab (diff)
cmake: Refactor all convenience library generation into a function.
-rw-r--r--CMakeLists.txt8
-rw-r--r--cmake/ConvenienceLibrary.cmake19
-rw-r--r--dispatch/CMakeLists.txt14
-rw-r--r--helpers/CMakeLists.txt6
-rw-r--r--thirdparty/libbacktrace/CMakeLists.txt5
-rw-r--r--thirdparty/libpng/CMakeLists.txt6
-rw-r--r--thirdparty/snappy/CMakeLists.txt6
-rw-r--r--thirdparty/zlib/CMakeLists.txt6
8 files changed, 28 insertions, 42 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2910deb..cc53832e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,7 @@ if (NOT WIN32)
endif ()
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
+include (ConvenienceLibrary)
if (ANDROID)
set (ENABLE_GUI false)
@@ -335,7 +336,7 @@ else ()
set (os os_posix.cpp)
endif ()
-add_library (common STATIC
+add_convenience_library (common
common/trace_callset.cpp
common/trace_dump.cpp
common/trace_fast_callset.cpp
@@ -358,11 +359,6 @@ add_library (common STATIC
common/highlight.cpp
)
-set_target_properties (common PROPERTIES
- # Ensure it can be statically linked in shared libraries
- COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
-)
-
target_link_libraries (common
${LIBBACKTRACE_LIBRARIES}
)
diff --git a/cmake/ConvenienceLibrary.cmake b/cmake/ConvenienceLibrary.cmake
new file mode 100644
index 00000000..bf18b381
--- /dev/null
+++ b/cmake/ConvenienceLibrary.cmake
@@ -0,0 +1,19 @@
+# Function for convenience libraries, ie., libraries which can be statically
+# linked into shared libraries.
+function (add_convenience_library)
+
+ set (name "${ARGV0}")
+ list (REMOVE_AT ARGV 0)
+
+ add_library ("${name}" STATIC ${ARGV})
+
+ if (NOT "${CMAKE_SHARED_LIBRARY_C_FLAGS}" STREQUAL "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
+ message (FATAL_ERROR "CMAKE_SHARED_LIBRARY_C_FLAGS (${CMAKE_SHARED_LIBRARY_C_FLAGS}) != CMAKE_SHARED_LIBRARY_CXX_FLAGS (${CMAKE_SHARED_LIBRARY_CXX_FLAGS})")
+ endif ()
+
+ set_target_properties ("${name}" PROPERTIES
+ # Ensure it can be statically linked in shared libraries
+ COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
+ )
+
+endfunction ()
diff --git a/dispatch/CMakeLists.txt b/dispatch/CMakeLists.txt
index 0dad67fe..5892c700 100644
--- a/dispatch/CMakeLists.txt
+++ b/dispatch/CMakeLists.txt
@@ -29,27 +29,17 @@ add_custom_command (
add_custom_target (glproc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
-add_library (glproc_gl STATIC EXCLUDE_FROM_ALL
+add_convenience_library (glproc_gl EXCLUDE_FROM_ALL
glproc_gl.cpp
)
add_dependencies (glproc_gl glproc)
-set_target_properties (glproc_gl PROPERTIES
- # Ensure it can be statically linked in shared libraries
- COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
-)
-
if (ENABLE_EGL)
- add_library (glproc_egl STATIC EXCLUDE_FROM_ALL
+ add_convenience_library (glproc_egl EXCLUDE_FROM_ALL
glproc_egl.cpp
)
add_dependencies (glproc_egl glproc)
-
- set_target_properties (glproc_egl PROPERTIES
- # Ensure it can be statically linked in shared libraries
- COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
- )
endif ()
diff --git a/helpers/CMakeLists.txt b/helpers/CMakeLists.txt
index 53a639fc..235ef36a 100644
--- a/helpers/CMakeLists.txt
+++ b/helpers/CMakeLists.txt
@@ -3,11 +3,7 @@
if (WIN32)
- add_library (d3dhelpers STATIC
+ add_convenience_library (d3dhelpers
d3dshader.cpp
)
- set_target_properties (d3dhelpers PROPERTIES
- # Ensure it can be statically linked in shared libraries
- COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
- )
endif ()
diff --git a/thirdparty/libbacktrace/CMakeLists.txt b/thirdparty/libbacktrace/CMakeLists.txt
index 26604200..fed008e2 100644
--- a/thirdparty/libbacktrace/CMakeLists.txt
+++ b/thirdparty/libbacktrace/CMakeLists.txt
@@ -133,7 +133,7 @@ include_directories (BEFORE
include_directories (
auxincl
)
-add_library (backtrace STATIC EXCLUDE_FROM_ALL
+add_convenience_library (backtrace EXCLUDE_FROM_ALL
${BACKTRACE_FILE}
${FORMAT_FILE}
${VIEW_FILE}
@@ -143,9 +143,6 @@ add_library (backtrace STATIC EXCLUDE_FROM_ALL
print.c
state.c
)
-set_target_properties (backtrace PROPERTIES
- COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
-)
set (ENABLE_LIBBACKTRACE_TEST false CACHE BOOL "Enable libbacktrace testing")
if (ENABLE_LIBBACKTRACE_TEST)
diff --git a/thirdparty/libpng/CMakeLists.txt b/thirdparty/libpng/CMakeLists.txt
index 7cf2be90..eebed880 100644
--- a/thirdparty/libpng/CMakeLists.txt
+++ b/thirdparty/libpng/CMakeLists.txt
@@ -1,6 +1,6 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-add_library (png_bundled STATIC EXCLUDE_FROM_ALL
+add_convenience_library (png_bundled EXCLUDE_FROM_ALL
png.c
pngerror.c
pngget.c
@@ -18,10 +18,6 @@ add_library (png_bundled STATIC EXCLUDE_FROM_ALL
pngwutil.c
)
-set_target_properties (png_bundled PROPERTIES
- COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
-)
-
install (
FILES LICENSE
DESTINATION ${DOC_INSTALL_DIR}
diff --git a/thirdparty/snappy/CMakeLists.txt b/thirdparty/snappy/CMakeLists.txt
index 25281a6b..18d1f4bb 100644
--- a/thirdparty/snappy/CMakeLists.txt
+++ b/thirdparty/snappy/CMakeLists.txt
@@ -8,17 +8,13 @@ if (CMAKE_COMPILER_IS_GNUCXX)
add_definitions (-Wno-unused-function)
endif ()
-add_library (snappy_bundled STATIC EXCLUDE_FROM_ALL
+add_convenience_library (snappy_bundled EXCLUDE_FROM_ALL
snappy.cc
snappy-sinksource.cc
snappy-stubs-internal.cc
snappy-c.cc
)
-set_target_properties (snappy_bundled PROPERTIES
- COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
-)
-
install (
FILES COPYING
DESTINATION ${DOC_INSTALL_DIR}
diff --git a/thirdparty/zlib/CMakeLists.txt b/thirdparty/zlib/CMakeLists.txt
index 710855de..c76f9e7a 100644
--- a/thirdparty/zlib/CMakeLists.txt
+++ b/thirdparty/zlib/CMakeLists.txt
@@ -7,7 +7,7 @@ else ()
add_definitions (-DHAVE_UNISTD_H)
endif ()
-add_library (z_bundled STATIC EXCLUDE_FROM_ALL
+add_convenience_library (z_bundled EXCLUDE_FROM_ALL
adler32.c
compress.c
crc32.c
@@ -25,10 +25,6 @@ add_library (z_bundled STATIC EXCLUDE_FROM_ALL
zutil.c
)
-set_target_properties (z_bundled PROPERTIES
- COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
-)
-
install (
FILES README
DESTINATION ${DOC_INSTALL_DIR}