diff options
author | Dmitry Marakasov <amdmi3@amdmi3.ru> | 2013-07-30 22:41:51 +0400 |
---|---|---|
committer | Dmitry Marakasov <amdmi3@amdmi3.ru> | 2013-07-31 06:15:26 +0400 |
commit | 89dd7ed0111d2aebe5d362052f8582bfc17c7cbc (patch) | |
tree | e4287c6b2c71adad895da215b443e2545c467260 | |
parent | 5ac7f3d99084d519e7eddcf40e7d81e8b91400f0 (diff) |
Add detection of required libraries
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | cmake/FindLIBCONFIG.cmake | 15 | ||||
-rw-r--r-- | cmake/FindSODIUM.cmake | 15 | ||||
-rw-r--r-- | core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | other/bootstrap_serverdaemon/CMakeLists.txt | 6 |
5 files changed, 43 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c16ce6fe..c18d41d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -1,11 +1,14 @@ | |||
1 | cmake_minimum_required(VERSION 2.6.0) | 1 | cmake_minimum_required(VERSION 2.6.0) |
2 | 2 | ||
3 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | ||
4 | |||
3 | #MinGW prints more warnings for -Wall than gcc does, thus causing build to fail | 5 | #MinGW prints more warnings for -Wall than gcc does, thus causing build to fail |
4 | if(NOT WIN32) | 6 | if(NOT WIN32) |
5 | if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) | 7 | if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) |
6 | message(STATUS "==== ${CMAKE_C_COMPILER_ID} detected - Adding compiler flags ====") | 8 | message(STATUS "==== ${CMAKE_C_COMPILER_ID} detected - Adding compiler flags ====") |
7 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") | 9 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") |
8 | endif() | 10 | endif() |
11 | find_package(SODIUM REQUIRED) | ||
9 | endif() | 12 | endif() |
10 | 13 | ||
11 | macro(linkCoreLibraries exe_name) | 14 | macro(linkCoreLibraries exe_name) |
@@ -16,8 +19,9 @@ macro(linkCoreLibraries exe_name) | |||
16 | ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a | 19 | ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a |
17 | ws2_32) | 20 | ws2_32) |
18 | else() | 21 | else() |
22 | include_directories(${SODIUM_INCLUDE_DIR}) | ||
19 | target_link_libraries(${exe_name} core | 23 | target_link_libraries(${exe_name} core |
20 | sodium) | 24 | ${SODIUM_LIBRARY}) |
21 | endif() | 25 | endif() |
22 | endmacro() | 26 | endmacro() |
23 | 27 | ||
@@ -25,4 +29,4 @@ cmake_policy(SET CMP0011 NEW) | |||
25 | 29 | ||
26 | add_subdirectory(core) | 30 | add_subdirectory(core) |
27 | add_subdirectory(testing) | 31 | add_subdirectory(testing) |
28 | add_subdirectory(other) \ No newline at end of file | 32 | add_subdirectory(other) |
diff --git a/cmake/FindLIBCONFIG.cmake b/cmake/FindLIBCONFIG.cmake new file mode 100644 index 00000000..d5018240 --- /dev/null +++ b/cmake/FindLIBCONFIG.cmake | |||
@@ -0,0 +1,15 @@ | |||
1 | # Find LIBCONFIG | ||
2 | # | ||
3 | # LIBCONFIG_INCLUDE_DIR | ||
4 | # LIBCONFIG_LIBRARY | ||
5 | # LIBCONFIG_FOUND | ||
6 | # | ||
7 | |||
8 | FIND_PATH(LIBCONFIG_INCLUDE_DIR NAMES libconfig.h) | ||
9 | |||
10 | FIND_LIBRARY(LIBCONFIG_LIBRARY NAMES config) | ||
11 | |||
12 | INCLUDE(FindPackageHandleStandardArgs) | ||
13 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBCONFIG DEFAULT_MSG LIBCONFIG_LIBRARY LIBCONFIG_INCLUDE_DIR) | ||
14 | |||
15 | MARK_AS_ADVANCED(LIBCONFIG_INCLUDE_DIR LIBCONFIG_LIBRARY) | ||
diff --git a/cmake/FindSODIUM.cmake b/cmake/FindSODIUM.cmake new file mode 100644 index 00000000..ffb6a1f7 --- /dev/null +++ b/cmake/FindSODIUM.cmake | |||
@@ -0,0 +1,15 @@ | |||
1 | # Find SODIUM | ||
2 | # | ||
3 | # SODIUM_INCLUDE_DIR | ||
4 | # SODIUM_LIBRARY | ||
5 | # SODIUM_FOUND | ||
6 | # | ||
7 | |||
8 | FIND_PATH(SODIUM_INCLUDE_DIR NAMES sodium.h) | ||
9 | |||
10 | FIND_LIBRARY(SODIUM_LIBRARY NAMES sodium) | ||
11 | |||
12 | INCLUDE(FindPackageHandleStandardArgs) | ||
13 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(SODIUM DEFAULT_MSG SODIUM_LIBRARY SODIUM_INCLUDE_DIR) | ||
14 | |||
15 | MARK_AS_ADVANCED(SODIUM_INCLUDE_DIR SODIUM_LIBRARY) | ||
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 420308d8..44ae980c 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt | |||
@@ -3,6 +3,8 @@ project(core C) | |||
3 | 3 | ||
4 | if(WIN32) | 4 | if(WIN32) |
5 | include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) | 5 | include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) |
6 | else(WIN32) | ||
7 | include_directories(${SODIUM_INCLUDE_DIR}) | ||
6 | endif() | 8 | endif() |
7 | 9 | ||
8 | set(core_sources | 10 | set(core_sources |
diff --git a/other/bootstrap_serverdaemon/CMakeLists.txt b/other/bootstrap_serverdaemon/CMakeLists.txt index 57ba4841..a9cfdff7 100644 --- a/other/bootstrap_serverdaemon/CMakeLists.txt +++ b/other/bootstrap_serverdaemon/CMakeLists.txt | |||
@@ -3,10 +3,14 @@ project(DHT_bootstrap_daemon C) | |||
3 | 3 | ||
4 | set(exe_name DHT_bootstrap_daemon) | 4 | set(exe_name DHT_bootstrap_daemon) |
5 | 5 | ||
6 | find_package(LIBCONFIG REQUIRED) | ||
7 | |||
8 | include_directories(${LIBCONFIG_INCLUDE_DIR}) | ||
9 | |||
6 | add_executable(${exe_name} | 10 | add_executable(${exe_name} |
7 | DHT_bootstrap_daemon.c) | 11 | DHT_bootstrap_daemon.c) |
8 | 12 | ||
9 | target_link_libraries(${exe_name} | 13 | target_link_libraries(${exe_name} |
10 | config) | 14 | ${LIBCONFIG_LIBRARY}) |
11 | 15 | ||
12 | linkCoreLibraries(${exe_name}) | 16 | linkCoreLibraries(${exe_name}) |