Skip to content

Commit

Permalink
Added build options.
Browse files Browse the repository at this point in the history
Added an option to build the library even if it is not installed. This is necessary for the Arch Linux split package.
  • Loading branch information
branoholy committed Mar 7, 2016
1 parent d81e2b4 commit 3623908
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ if(${PROJECT_VERSION_TWEAK})
endif()

# Set options
option(build-library "Build the library even if only the headers are installed")
option(install-library "Install the library only (no headers)")
option(install-headers "Install the headers only (no library)")
option(example "Build the console example")
option(example-gui "Build the GUI example")
option(examples "Build all examples")
option(examples-only "Build only examples (not the library)")
option(install-headers "Install the headers only (no library)")
option(install-library "Install the library only (no headers)")

option(INSTALL_LIB_DIR "Installation directory for libraries")
if(${INSTALL_LIB_DIR} STREQUAL "OFF")
Expand Down Expand Up @@ -59,7 +60,8 @@ if(${examples-only} STREQUAL "OFF")
# Include headers
include_directories("include")

if(${install-headers} STREQUAL "OFF")
# Build library
if((${build-library}) OR (${install-headers} STREQUAL "OFF"))
# Find source code
file(GLOB_RECURSE CPPS "src/regilo/*.cpp")
file(GLOB_RECURSE HPPS "include/regilo/*.hpp")
Expand All @@ -72,14 +74,17 @@ if(${examples-only} STREQUAL "OFF")
add_library(${PROJECT_NAME} SHARED ${CPPS} ${HPPS})
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")

# Install library
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${INSTALL_LIB_DIR})

# Link libraries
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif()

# Install library
if(${install-headers} STREQUAL "OFF")
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${INSTALL_LIB_DIR})
endif()

# Install headers
if(${install-library} STREQUAL "OFF")
install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION include/${PROJECT_NAME})
endif()
Expand Down

0 comments on commit 3623908

Please sign in to comment.