diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a28a7c43..715147291 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -635,6 +635,26 @@ else() message(STATUS "JNI library is disabled") endif() +# Installation and packaging +if(WIN32) + option(ROCKSDB_INSTALL_ON_WINDOWS "Enable install target on Windows" OFF) +endif() +if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS) + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + # Change default installation prefix on Linux to /usr + set(CMAKE_INSTALL_PREFIX /usr CACHE PATH "Install path prefix, prepended onto install directories." FORCE) + endif() + endif() + + include(GNUInstallDirs) + install(TARGETS ${ROCKSDB_STATIC_LIB} COMPONENT devel ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${ROCKSDB_SHARED_LIB} COMPONENT runtime DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(DIRECTORY include/rocksdb COMPONENT devel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif() + +option(WITH_TESTS "build with tests" ON) +if(WITH_TESTS) set(TESTS cache/cache_test.cc cache/lru_cache_test.cc @@ -846,14 +866,9 @@ foreach(sourcefile ${C_TEST_EXES}) add_test(NAME ${exename} COMMAND ${exename}${ARTIFACT_SUFFIX}) add_dependencies(check ${exename}${ARTIFACT_SUFFIX}) endforeach(sourcefile ${C_TEST_EXES}) -add_subdirectory(tools) +endif() -# Installation and packaging for Linux -if(NOT WIN32) -install(TARGETS ${ROCKSDB_STATIC_LIB} COMPONENT devel ARCHIVE DESTINATION lib64) -install(TARGETS ${ROCKSDB_SHARED_LIB} COMPONENT runtime DESTINATION lib64) -install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/rocksdb/" - COMPONENT devel - DESTINATION include/rocksdb) -set(CMAKE_INSTALL_PREFIX /usr) +option(WITH_TOOLS "build with tools" ON) +if(WITH_TOOLS) + add_subdirectory(tools) endif()