Skip to content

Commit 07db285

Browse files
authored
Merge pull request #72 from kou/installable
Make installable
2 parents 8c79d2c + bb39b01 commit 07db285

File tree

4 files changed

+72
-23
lines changed

4 files changed

+72
-23
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
*.VC.db
1111
*.VC.opendb
1212
*.vcxproj.user
13+
/fastpfor.pc
14+
/FastPFORConfig.cmake

CMakeLists.txt

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
1616
include(AppendCompilerFlags)
1717

1818

19-
project(FastPFor CXX C)
19+
project(FastPFOR CXX C)
2020
set(PROJECT_URL "https://github.com/lemire/FastPFOR")
2121
set(PROJECT_DESCRIPTION "The FastPFOR C++ library: Fast integer compression")
22+
# Need to bump this when we release a new version.
23+
set(PROJECT_VERSION "0.1.9")
2224

2325
include(DetectCPUFeatures)
2426
#
@@ -106,17 +108,16 @@ MESSAGE( STATUS "CMAKE_C_FLAGS_RELEASE: " ${CMAKE_C_FLAGS_RELEASE} )
106108

107109
# library target
108110
include_directories(headers)
109-
add_library(FastPFor STATIC src/bitpacking.cpp
110-
src/bitpacking.cpp
111-
src/bitpackingaligned.cpp
112-
src/bitpackingunaligned.cpp
113-
src/horizontalbitpacking.cpp
114-
src/simdunalignedbitpacking.cpp
115-
src/simdbitpacking.cpp
116-
src/varintdecode.c
117-
src/streamvbyte.c
118-
${HEADERS}
119-
)
111+
add_library(FastPFOR STATIC
112+
src/bitpacking.cpp
113+
src/bitpackingaligned.cpp
114+
src/bitpackingunaligned.cpp
115+
src/horizontalbitpacking.cpp
116+
src/simdunalignedbitpacking.cpp
117+
src/simdbitpacking.cpp
118+
src/varintdecode.c
119+
src/streamvbyte.c)
120+
set_target_properties(FastPFOR PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
120121

121122

122123
# other executables
@@ -125,11 +126,11 @@ add_executable(partitionbylength src/partitionbylength.cpp)
125126
add_executable(csv2maropu src/csv2maropu.cpp)
126127

127128
add_executable(entropy src/entropy.cpp)
128-
target_link_libraries(entropy FastPFor)
129+
target_link_libraries(entropy FastPFOR)
129130

130131
if( SUPPORT_SSE42 )
131132
add_executable(benchbitpacking src/benchbitpacking.cpp)
132-
target_link_libraries(benchbitpacking FastPFor)
133+
target_link_libraries(benchbitpacking FastPFOR)
133134
endif()
134135

135136
find_package(snappy)
@@ -142,11 +143,11 @@ else()
142143
include_directories(${snappy_INCLUDE_DIRS})
143144
add_executable(codecssnappy src/codecs.cpp)
144145
set_target_properties(codecssnappy PROPERTIES DEFINE_SYMBOL USESNAPPY)
145-
target_link_libraries(codecssnappy FastPFor ${snappy_LIBRARIES})
146+
target_link_libraries(codecssnappy FastPFOR ${snappy_LIBRARIES})
146147

147148
add_executable(inmemorybenchmarksnappy src/inmemorybenchmark.cpp)
148149
set_target_properties(inmemorybenchmarksnappy PROPERTIES DEFINE_SYMBOL USESNAPPY)
149-
target_link_libraries(inmemorybenchmarksnappy FastPFor ${snappy_LIBRARIES})
150+
target_link_libraries(inmemorybenchmarksnappy FastPFOR ${snappy_LIBRARIES})
150151
endif()
151152

152153
# Download and unpack googletest at configure time
@@ -184,25 +185,57 @@ if(CMAKE_VERSION VERSION_LESS 2.8.11)
184185
endif()
185186

186187
add_executable(codecs src/codecs.cpp)
187-
target_link_libraries(codecs FastPFor)
188+
target_link_libraries(codecs FastPFOR)
188189

189190
add_executable(example example.cpp)
190-
target_link_libraries(example FastPFor)
191+
target_link_libraries(example FastPFOR)
191192

192193
add_executable(inmemorybenchmark src/inmemorybenchmark.cpp)
193-
target_link_libraries(inmemorybenchmark FastPFor)
194+
target_link_libraries(inmemorybenchmark FastPFOR)
194195

195196
add_executable(unit src/unit.cpp)
196-
target_link_libraries(unit FastPFor)
197+
target_link_libraries(unit FastPFOR)
197198
add_custom_target(check unit DEPENDS unit)
198199

199200

200-
add_executable(FastPFor_unittest
201+
add_executable(FastPFOR_unittest
201202
unittest/test_composite.cpp
202203
unittest/test_driver.cpp
203204
unittest/test_fastpfor.cpp
204205
unittest/test_variablebyte.cpp)
205-
target_link_libraries(FastPFor_unittest gtest FastPFor)
206+
target_link_libraries(FastPFOR_unittest gtest FastPFOR)
206207
enable_testing()
207208
add_test("unit" unit)
208-
add_test("FastPFor_unittest" FastPFor_unittest)
209+
add_test("FastPFOR_unittest" FastPFOR_unittest)
210+
211+
212+
include(GNUInstallDirs)
213+
install(TARGETS FastPFOR
214+
EXPORT FastPFORExport
215+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
216+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
217+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
218+
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
219+
set(PACKAGE_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/FastPFOR")
220+
install(EXPORT FastPFORExport
221+
FILE "FastPFORTargets.cmake"
222+
DESTINATION "${PACKAGE_CMAKE_INSTALL_DIR}"
223+
NAMESPACE "FastPFOR::")
224+
install(DIRECTORY "headers/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/fastpfor")
225+
install(FILES AUTHORS LICENSE README.md
226+
DESTINATION "${CMAKE_INSTALL_DOCDIR}")
227+
if(NOT CMAKE_VERSION VERSION_LESS 3.0.0)
228+
include(CMakePackageConfigHelpers)
229+
configure_package_config_file("FastPFORConfig.cmake.in"
230+
"${CMAKE_CURRENT_BINARY_DIR}/FastPFORConfig.cmake"
231+
INSTALL_DESTINATION "${PACKAGE_CMAKE_INSTALL_DIR}")
232+
write_basic_package_version_file("FastPFORConfigVersion.cmake"
233+
COMPATIBILITY SameMajorVersion)
234+
install(FILES
235+
"${CMAKE_CURRENT_BINARY_DIR}/FastPFORConfig.cmake"
236+
"${CMAKE_CURRENT_BINARY_DIR}/FastPFORConfigVersion.cmake"
237+
DESTINATION "${PACKAGE_CMAKE_INSTALL_DIR}")
238+
endif()
239+
configure_file("fastpfor.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/fastpfor.pc" @ONLY)
240+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/fastpfor.pc"
241+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

FastPFORConfig.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
if(NOT TARGET FastPFOR)
4+
include("${CMAKE_CURRENT_LIST_DIR}/FastPFORTargets.cmake")
5+
endif()

fastpfor.pc.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
3+
includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@
4+
5+
Name: FastPFOR
6+
Description: @PROJECT_DESCRIPTION@
7+
Version: @PROJECT_VERSION@
8+
Libs: -L${libdir} -lFastPFOR
9+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)