Line 0
Link Here
|
|
|
1 |
From 5ab73ee82245b586f69762411edc7824d778ee2a Mon Sep 17 00:00:00 2001 |
2 |
From: Chris Kitching <chriskitching@linux.com> |
3 |
Date: Tue, 15 Nov 2016 10:15:48 +0000 |
4 |
Subject: [PATCH] Rely on BUILD_SHARED_LIBS instead of custom options |
5 |
|
6 |
Instead of having your own option for choosing between static |
7 |
and shared versions of the library, use cmake's built-in option |
8 |
for this: |
9 |
https://cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html |
10 |
|
11 |
Set -DBUILD_SHARED_LIBS=ON to get a shared library, and omit it |
12 |
or set it to OFF to get a static one. |
13 |
Can add one extra line to the cmake file to make the default be |
14 |
shared. Makes most of the cmake crap go away. |
15 |
--- |
16 |
cmake_unofficial/CMakeLists.txt | 23 +++++------------------ |
17 |
1 file changed, 5 insertions(+), 18 deletions(-) |
18 |
|
19 |
diff --git a/cmake_unofficial/CMakeLists.txt b/cmake_unofficial/CMakeLists.txt |
20 |
index 0d7cf74..b91acf4 100644 |
21 |
--- cmake_unofficial/CMakeLists.txt |
22 |
+++ cmake_unofficial/CMakeLists.txt |
23 |
@@ -6,27 +6,14 @@ project(xxhash) |
24 |
set(XXHASH_LIB_VERSION "0.42.0") |
25 |
set(XXHASH_LIB_SOVERSION "0") |
26 |
|
27 |
-option(BUILD_SHARED_LIBS "Set to ON to build shared libraries" ON) |
28 |
-option(BUILD_STATIC_LIBS "Set to ON to build static libraries" ON) |
29 |
- |
30 |
-if(BUILD_SHARED_LIBS) |
31 |
- add_library(xxhash SHARED ../xxhash.c) |
32 |
- set_target_properties(xxhash PROPERTIES COMPILE_DEFINITIONS "XXHASH_EXPORT" |
33 |
- VERSION "${XXHASH_LIB_VERSION}" |
34 |
- SOVERSION "${XXHASH_LIB_SOVERSION}") |
35 |
- LIST(APPEND install_libs xxhash) |
36 |
-endif(BUILD_SHARED_LIBS) |
37 |
- |
38 |
-if(BUILD_STATIC_LIBS) |
39 |
- add_library(xxhashstatic ../xxhash.c) |
40 |
- set_target_properties(xxhashstatic PROPERTIES OUTPUT_NAME xxhash) |
41 |
- LIST(APPEND install_libs xxhashstatic) |
42 |
-endif(BUILD_STATIC_LIBS) |
43 |
- |
44 |
+add_library(xxhash ../xxhash.c) |
45 |
+set_target_properties(xxhash PROPERTIES COMPILE_DEFINITIONS "XXHASH_EXPORT" |
46 |
+ VERSION "${XXHASH_LIB_VERSION}" |
47 |
+ SOVERSION "${XXHASH_LIB_SOVERSION}") |
48 |
|
49 |
INSTALL(FILES ../xxhash.h DESTINATION include) |
50 |
INSTALL( |
51 |
- TARGETS ${install_libs} |
52 |
+ TARGETS xxhash |
53 |
RUNTIME DESTINATION bin |
54 |
ARCHIVE DESTINATION lib |
55 |
LIBRARY DESTINATION lib |