Ticket #55583: patch-build-shared+static.diff
File patch-build-shared+static.diff, 2.6 KB (added by RJVB (René Bertin), 7 years ago) |
---|
-
CMakeLists.txt
diff --git CMakeLists.txt CMakeLists.txt index 3f534b134eb8421b6cb34f6416b0a854144f92f5..68a24f05f08613c0af851e5f98f6a46e85378d61 100644
project(Snappy VERSION 1.1.7 LANGUAGES C CXX) 3 3 4 4 # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make 5 5 # it prominent in the GUI. 6 option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF)6 # option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF) 7 7 8 8 option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON) 9 9 … … configure_file( 72 72 "${PROJECT_SOURCE_DIR}/snappy-stubs-public.h.in" 73 73 "${PROJECT_BINARY_DIR}/snappy-stubs-public.h") 74 74 75 add_library(snappy "")75 add_library(snappy SHARED "") 76 76 target_sources(snappy 77 77 PRIVATE 78 78 "${PROJECT_SOURCE_DIR}/snappy-internal.h" … … if(BUILD_SHARED_LIBS) 108 108 set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) 109 109 endif(BUILD_SHARED_LIBS) 110 110 111 add_library(staticlib STATIC "") 112 target_sources(staticlib 113 PRIVATE 114 "${PROJECT_SOURCE_DIR}/snappy-internal.h" 115 "${PROJECT_SOURCE_DIR}/snappy-stubs-internal.h" 116 "${PROJECT_SOURCE_DIR}/snappy-c.cc" 117 "${PROJECT_SOURCE_DIR}/snappy-sinksource.cc" 118 "${PROJECT_SOURCE_DIR}/snappy-stubs-internal.cc" 119 "${PROJECT_SOURCE_DIR}/snappy.cc" 120 "${PROJECT_BINARY_DIR}/config.h" 121 122 # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install". 123 $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC> 124 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h> 125 $<INSTALL_INTERFACE:include/snappy-c.h> 126 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h> 127 $<INSTALL_INTERFACE:include/snappy-sinksource.h> 128 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy.h> 129 $<INSTALL_INTERFACE:include/snappy.h> 130 $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snappy-stubs-public.h> 131 $<INSTALL_INTERFACE:include/snappy-stubs-public.h> 132 ) 133 target_include_directories(staticlib 134 PUBLIC 135 $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}> 136 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> 137 $<INSTALL_INTERFACE:include> 138 ) 139 set_target_properties(staticlib 140 PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} 141 OUTPUT_NAME snappy 142 ) 143 144 target_compile_definitions(staticlib PRIVATE -DHAVE_CONFIG_H) 145 111 146 if(SNAPPY_BUILD_TESTS) 112 147 enable_testing() 113 148 … … if(SNAPPY_BUILD_TESTS) 141 176 endif(SNAPPY_BUILD_TESTS) 142 177 143 178 include(GNUInstallDirs) 144 install(TARGETS snappy 179 install(TARGETS snappy staticlib 145 180 EXPORT SnappyTargets 146 181 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 147 182 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}