Commit a37bdd935a1615b31797ae121372a523afabe00d
1 parent
48cad75d
Allow redox inclusion as cmake subdirectory.
Showing
1 changed file
with
23 additions
and
23 deletions
CMakeLists.txt
| @@ -7,7 +7,7 @@ set(REDOX_VERSION_PATCH 2) | @@ -7,7 +7,7 @@ set(REDOX_VERSION_PATCH 2) | ||
| 7 | set(REDOX_VERSION_STRING ${REDOX_VERSION_MAJOR}.${REDOX_VERSION_MINOR}.${REDOX_VERSION_PATCH}) | 7 | set(REDOX_VERSION_STRING ${REDOX_VERSION_MAJOR}.${REDOX_VERSION_MINOR}.${REDOX_VERSION_PATCH}) |
| 8 | 8 | ||
| 9 | option(lib "Build Redox as a dynamic library." ON) | 9 | option(lib "Build Redox as a dynamic library." ON) |
| 10 | -option(static_lib "Build Redox as a static library." OFF) | 10 | +option(static_lib "Build Redox as a static library." ON) |
| 11 | option(tests "Build all tests." OFF) | 11 | option(tests "Build all tests." OFF) |
| 12 | option(examples "Build all examples." OFF) | 12 | option(examples "Build all examples." OFF) |
| 13 | 13 | ||
| @@ -25,29 +25,29 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall") | @@ -25,29 +25,29 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall") | ||
| 25 | # Source files | 25 | # Source files |
| 26 | # --------------------------------------------------------- | 26 | # --------------------------------------------------------- |
| 27 | 27 | ||
| 28 | -set(SRC_DIR ${CMAKE_SOURCE_DIR}/src) | ||
| 29 | -set(INC_DIR ${CMAKE_SOURCE_DIR}/include) | 28 | +set(SRC_REDOX_DIR ${PROJECT_SOURCE_DIR}/src) |
| 29 | +set(INC_REDOX_DIR ${PROJECT_SOURCE_DIR}/include) | ||
| 30 | 30 | ||
| 31 | -set(SRC_CORE | ||
| 32 | - ${SRC_DIR}/client.cpp | ||
| 33 | - ${SRC_DIR}/command.cpp | ||
| 34 | - ${SRC_DIR}/subscriber.cpp) | 31 | +set(SRC_REDOX_CORE |
| 32 | + ${SRC_REDOX_DIR}/client.cpp | ||
| 33 | + ${SRC_REDOX_DIR}/command.cpp | ||
| 34 | + ${SRC_REDOX_DIR}/subscriber.cpp) | ||
| 35 | 35 | ||
| 36 | -set(INC_CORE | ||
| 37 | - ${INC_DIR}/redox/client.hpp | ||
| 38 | - ${INC_DIR}/redox/subscriber.hpp | ||
| 39 | - ${INC_DIR}/redox/command.hpp) | 36 | +set(INC_REDOX_CORE |
| 37 | + ${INC_REDOX_DIR}/redox/client.hpp | ||
| 38 | + ${INC_REDOX_DIR}/redox/subscriber.hpp | ||
| 39 | + ${INC_REDOX_DIR}/redox/command.hpp) | ||
| 40 | 40 | ||
| 41 | -set(SRC_UTILS ${SRC_DIR}/utils/logger.cpp) | ||
| 42 | -set(INC_UTILS ${INC_DIR}/redox/utils/logger.hpp) | 41 | +set(SRC_REDOX_UTILS ${SRC_REDOX_DIR}/utils/logger.cpp) |
| 42 | +set(INC_REDOX_UTILS ${INC_REDOX_DIR}/redox/utils/logger.hpp) | ||
| 43 | 43 | ||
| 44 | -set(INC_WRAPPER ${INC_DIR}/redox.hpp) | 44 | +set(INC_REDOX_WRAPPER ${INC_REDOX_DIR}/redox.hpp) |
| 45 | 45 | ||
| 46 | -set(SRC_ALL ${SRC_CORE} ${SRC_UTILS}) | ||
| 47 | -set(INC_ALL ${INC_CORE} ${INC_UTILS} ${INC_WRAPPER}) | 46 | +set(SRC_REDOX_ALL ${SRC_REDOX_CORE} ${SRC_REDOX_UTILS}) |
| 47 | +set(INC_REDOX_ALL ${INC_REDOX_CORE} ${INC_REDOX_UTILS} ${INC_REDOX_WRAPPER}) | ||
| 48 | 48 | ||
| 49 | -include_directories(${INC_DIR}) | ||
| 50 | -include_directories(${INC_DIR}/redox) | 49 | +include_directories(${INC_REDOX_DIR}) |
| 50 | +include_directories(${INC_REDOX_DIR}/redox) | ||
| 51 | 51 | ||
| 52 | # Dependent libraries - you may have to change | 52 | # Dependent libraries - you may have to change |
| 53 | # pthread to whatever C++11 threads depends on | 53 | # pthread to whatever C++11 threads depends on |
| @@ -60,7 +60,7 @@ set(REDOX_LIB_DEPS ev pthread hiredis) | @@ -60,7 +60,7 @@ set(REDOX_LIB_DEPS ev pthread hiredis) | ||
| 60 | 60 | ||
| 61 | if (lib) | 61 | if (lib) |
| 62 | 62 | ||
| 63 | - add_library(redox SHARED ${SRC_ALL} ${INC_CORE}) | 63 | + add_library(redox SHARED ${SRC_REDOX_ALL} ${INC_REDOX_CORE}) |
| 64 | target_link_libraries(redox ${REDOX_LIB_DEPS}) | 64 | target_link_libraries(redox ${REDOX_LIB_DEPS}) |
| 65 | 65 | ||
| 66 | set_target_properties(redox | 66 | set_target_properties(redox |
| @@ -71,7 +71,7 @@ endif() | @@ -71,7 +71,7 @@ endif() | ||
| 71 | 71 | ||
| 72 | if (static_lib) | 72 | if (static_lib) |
| 73 | 73 | ||
| 74 | - add_library(redox_static STATIC ${SRC_ALL}) | 74 | + add_library(redox_static STATIC ${SRC_REDOX_ALL}) |
| 75 | target_link_libraries(redox_static ${REDOX_LIB_DEPS}) | 75 | target_link_libraries(redox_static ${REDOX_LIB_DEPS}) |
| 76 | 76 | ||
| 77 | set_target_properties(redox_static | 77 | set_target_properties(redox_static |
| @@ -158,11 +158,11 @@ set(CMAKE_INSTALL_PREFIX /usr/) | @@ -158,11 +158,11 @@ set(CMAKE_INSTALL_PREFIX /usr/) | ||
| 158 | install(TARGETS redox DESTINATION lib) | 158 | install(TARGETS redox DESTINATION lib) |
| 159 | 159 | ||
| 160 | # Install the headers into /usr/include/redox | 160 | # Install the headers into /usr/include/redox |
| 161 | -install(FILES ${INC_CORE} DESTINATION include/redox) | ||
| 162 | -install(FILES ${INC_UTILS} DESTINATION include/redox/utils) | 161 | +install(FILES ${INC_REDOX_CORE} DESTINATION include/redox) |
| 162 | +install(FILES ${INC_REDOX_UTILS} DESTINATION include/redox/utils) | ||
| 163 | 163 | ||
| 164 | # Install the top-level header directly into /usr/include | 164 | # Install the top-level header directly into /usr/include |
| 165 | -install(FILES ${INC_WRAPPER} DESTINATION include) | 165 | +install(FILES ${INC_REDOX_WRAPPER} DESTINATION include) |
| 166 | 166 | ||
| 167 | # --------------------------------------------------------- | 167 | # --------------------------------------------------------- |
| 168 | # Create system package (make package) | 168 | # Create system package (make package) |