mirror of
https://github.com/vgough/encfs.git
synced 2024-11-25 01:13:12 +01:00
Better handle libraries' build
* Add USE_INTERNAL_EASYLOGGING cmake option * Use -fPIC if -DBUILD_SHARED_LIBS
This commit is contained in:
parent
1c273ecba5
commit
53196f1927
@ -18,9 +18,13 @@ option(IWYU "Build with IWYU analysis." OFF)
|
|||||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/cmake")
|
"${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||||
|
|
||||||
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/vendor/github.com/muflihun/easyloggingpp/cmake")
|
||||||
|
|
||||||
option (BUILD_UNIT_TESTS "build EncFS unit tests" ON)
|
option (BUILD_UNIT_TESTS "build EncFS unit tests" ON)
|
||||||
option (BUILD_SHARED_LIBS "build shared libraries" OFF)
|
|
||||||
option (USE_INTERNAL_TINYXML "use built-in TinyXML2" ON)
|
option (USE_INTERNAL_TINYXML "use built-in TinyXML2" ON)
|
||||||
|
option (USE_INTERNAL_EASYLOGGING "use built-in Easylogging++" ON)
|
||||||
|
option (BUILD_SHARED_LIBS "build internal libraries as shared" OFF)
|
||||||
option (ENABLE_NLS "compile with Native Language Support (using gettext)" ON)
|
option (ENABLE_NLS "compile with Native Language Support (using gettext)" ON)
|
||||||
option (INSTALL_LIBENCFS "install libencfs" OFF)
|
option (INSTALL_LIBENCFS "install libencfs" OFF)
|
||||||
option (LINT "enable lint output" OFF)
|
option (LINT "enable lint output" OFF)
|
||||||
@ -49,6 +53,11 @@ endif ()
|
|||||||
# Let's enable some compilation warnings
|
# Let's enable some compilation warnings
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||||
|
|
||||||
|
# Let's enable some shared lib flags
|
||||||
|
if (BUILD_SHARED_LIBS)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_definitions( -DPACKAGE="encfs" )
|
add_definitions( -DPACKAGE="encfs" )
|
||||||
|
|
||||||
# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
|
# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
|
||||||
@ -194,8 +203,13 @@ endif()
|
|||||||
if (USE_INTERNAL_TINYXML)
|
if (USE_INTERNAL_TINYXML)
|
||||||
message("-- Using vendored TinyXML2")
|
message("-- Using vendored TinyXML2")
|
||||||
set(TINYXML_DIR vendor/github.com/leethomason/tinyxml2)
|
set(TINYXML_DIR vendor/github.com/leethomason/tinyxml2)
|
||||||
|
if (BUILD_SHARED_LIBS)
|
||||||
|
set(BUILD_STATIC_LIBS OFF CACHE BOOL "build static libs")
|
||||||
|
set(BUILD_SHARED_LIBS ON CACHE BOOL "build shared libs")
|
||||||
|
else ()
|
||||||
set(BUILD_STATIC_LIBS ON CACHE BOOL "build static libs")
|
set(BUILD_STATIC_LIBS ON CACHE BOOL "build static libs")
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "build shared libs")
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "build shared libs")
|
||||||
|
endif ()
|
||||||
set(BUILD_TESTS OFF CACHE BOOL "build tests")
|
set(BUILD_TESTS OFF CACHE BOOL "build tests")
|
||||||
add_subdirectory(${TINYXML_DIR} EXCLUDE_FROM_ALL)
|
add_subdirectory(${TINYXML_DIR} EXCLUDE_FROM_ALL)
|
||||||
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/${TINYXML_DIR})
|
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/${TINYXML_DIR})
|
||||||
@ -206,13 +220,23 @@ else ()
|
|||||||
include_directories (SYSTEM ${TINYXML_INCLUDE_DIR})
|
include_directories (SYSTEM ${TINYXML_INCLUDE_DIR})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
message("-- Using vendored easylogging++")
|
if (USE_INTERNAL_EASYLOGGING)
|
||||||
set(EASYLOGGING_DIR vendor/github.com/muflihun/easyloggingpp)
|
message("-- Using vendored Easylogging++")
|
||||||
set(build_static_lib ON CACHE BOOL "build static libs")
|
set(EASYLOGGING_DIR vendor/github.com/muflihun/easyloggingpp)
|
||||||
add_subdirectory(${EASYLOGGING_DIR} EXCLUDE_FROM_ALL)
|
if (BUILD_SHARED_LIBS)
|
||||||
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/${EASYLOGGING_DIR}/src)
|
set(build_static_lib OFF CACHE BOOL "build static libs")
|
||||||
link_directories(${CMAKE_BINARY_DIR}/${EASYLOGGING_DIR})
|
else ()
|
||||||
set(EASYLOGGING_LIBRARIES easyloggingpp)
|
set(build_static_lib ON CACHE BOOL "build static libs")
|
||||||
|
endif ()
|
||||||
|
add_subdirectory(${EASYLOGGING_DIR} EXCLUDE_FROM_ALL)
|
||||||
|
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/${EASYLOGGING_DIR}/src)
|
||||||
|
link_directories(${CMAKE_BINARY_DIR}/${EASYLOGGING_DIR})
|
||||||
|
set(EASYLOGGINGPP_LIBRARY easyloggingpp)
|
||||||
|
else ()
|
||||||
|
set(EASYLOGGINGPP_USE_SHARED_LIBS ON CACHE BOOL "look for shared lib")
|
||||||
|
find_package (EASYLOGGINGPP REQUIRED)
|
||||||
|
include_directories (SYSTEM ${EASYLOGGINGPP_INCLUDE_DIR})
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
encfs/autosprintf.cpp
|
encfs/autosprintf.cpp
|
||||||
@ -253,7 +277,7 @@ target_link_libraries(encfs
|
|||||||
${FUSE_LIBRARIES}
|
${FUSE_LIBRARIES}
|
||||||
${OPENSSL_LIBRARIES}
|
${OPENSSL_LIBRARIES}
|
||||||
${TINYXML_LIBRARIES}
|
${TINYXML_LIBRARIES}
|
||||||
${EASYLOGGING_LIBRARIES}
|
${EASYLOGGINGPP_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${Intl_LIBRARIES}
|
${Intl_LIBRARIES}
|
||||||
${ATOMIC_LIBRARY}
|
${ATOMIC_LIBRARY}
|
||||||
|
Loading…
Reference in New Issue
Block a user