diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/check_reqs.cmake | 12 | ||||
-rw-r--r-- | cmake/deps.cmake | 34 | ||||
-rw-r--r-- | cmake/fastd_module.cmake | 28 |
3 files changed, 49 insertions, 25 deletions
diff --git a/cmake/check_reqs.cmake b/cmake/check_reqs.cmake new file mode 100644 index 0000000..ad12ca7 --- /dev/null +++ b/cmake/check_reqs.cmake @@ -0,0 +1,12 @@ +set(HAVE_LIBSODIUM FALSE) + +get_property(nacl_required GLOBAL PROPERTY NACL_REQUIRED) +if(${nacl_required}) + if("${NACL_LIBRARIES}" STREQUAL "") + message(FATAL_ERROR "NaCl is not available, but a selected module needs it") + endif() + + if(USE_LIBSODIUM) + set(HAVE_LIBSODIUM TRUE) + endif(USE_LIBSODIUM) +endif(${nacl_required}) diff --git a/cmake/deps.cmake b/cmake/deps.cmake index fa3cb03..c3936af 100644 --- a/cmake/deps.cmake +++ b/cmake/deps.cmake @@ -17,24 +17,30 @@ set(NACL_LIBRARIES "") set(NACL_LDFLAGS_OTHER "") if(USE_LIBSODIUM) - pkg_check_modules(SODIUM REQUIRED libsodium) - - set(NACL_INCLUDE_DIRS "${SODIUM_INCLUDE_DIRS}") - foreach(dir "${SODIUM_INCLUDEDIR}" ${SODIUM_INCLUDE_DIRS}) - list(APPEND NACL_INCLUDE_DIRS "${dir}/sodium") - endforeach(dir) - - set(NACL_CFLAGS_OTHER "${SODIUM_CFLAGS_OTHER}") - set(NACL_LIBRARY_DIRS "${SODIUM_LIBRARY_DIRS}") - set(NACL_LIBRARIES "${SODIUM_LIBRARIES}") - set(NACL_LDFLAGS_OTHER "${SODIUM_LDFLAGS_OTHER}") + pkg_check_modules(SODIUM libsodium) + + if(SODIUM_FOUND) + set(NACL_INCLUDE_DIRS "${SODIUM_INCLUDE_DIRS}") + foreach(dir "${SODIUM_INCLUDEDIR}" ${SODIUM_INCLUDE_DIRS}) + list(APPEND NACL_INCLUDE_DIRS "${dir}/sodium") + endforeach(dir) + + set(NACL_CFLAGS_OTHER "${SODIUM_CFLAGS_OTHER}") + set(NACL_LIBRARY_DIRS "${SODIUM_LIBRARY_DIRS}") + set(NACL_LIBRARIES "${SODIUM_LIBRARIES}") + set(NACL_LDFLAGS_OTHER "${SODIUM_LDFLAGS_OTHER}") + endif(SODIUM_FOUND) else(USE_LIBSODIUM) - find_package(NaCl REQUIRED) + find_package(NaCl) - set(NACL_INCLUDE_DIRS "${NACL_INCLUDE_DIR}") - set(NACL_LIBRARIES "${NACL_LIBRARY}") + if(NACL_FOUND) + set(NACL_INCLUDE_DIRS "${NACL_INCLUDE_DIR}") + set(NACL_LIBRARIES "${NACL_LIBRARY}") + endif(NACL_FOUND) endif(USE_LIBSODIUM) +set_property(GLOBAL PROPERTY NACL_REQUIRED FALSE) + if(WITH_CAPABILITIES) find_package(CAP REQUIRED) diff --git a/cmake/fastd_module.cmake b/cmake/fastd_module.cmake index d18719a..d1b6d3b 100644 --- a/cmake/fastd_module.cmake +++ b/cmake/fastd_module.cmake @@ -1,9 +1,13 @@ -function(fastd_module type enabled_var info name) +macro(_fastd_module_handle_name) string(TOUPPER "${type}" TYPE) string(REPLACE - _ name_ "${name}") string(REPLACE " " _ name_ "${name_}") string(TOUPPER "${name_}" NAME) +endmacro(_fastd_module_handle_name) + +function(fastd_module type enabled_var info name) + _fastd_module_handle_name() set(WITH_${TYPE}_${NAME} TRUE CACHE BOOL "Include the ${name} ${info}") @@ -21,11 +25,7 @@ function(fastd_module type enabled_var info name) endfunction(fastd_module) function(fastd_module_include_directories type name) - string(TOUPPER "${type}" TYPE) - - string(REPLACE - _ name_ "${name}") - string(REPLACE " " _ name_ "${name_}") - string(TOUPPER "${name_}" NAME) + _fastd_module_handle_name() if(WITH_${TYPE}_${NAME}) target_include_directories(${type}_${name_} PRIVATE ${ARGN}) @@ -33,13 +33,19 @@ function(fastd_module_include_directories type name) endfunction(fastd_module_include_directories) function(fastd_module_link_libraries type name) - string(TOUPPER "${type}" TYPE) - - string(REPLACE - _ name_ "${name}") - string(REPLACE " " _ name_ "${name_}") - string(TOUPPER "${name_}" NAME) + _fastd_module_handle_name() if(WITH_${TYPE}_${NAME}) target_link_libraries(${type}_${name_} ${ARGN}) endif(WITH_${TYPE}_${NAME}) endfunction(fastd_module_link_libraries) + +function(fastd_module_require type name) + _fastd_module_handle_name() + + if(WITH_${TYPE}_${NAME}) + foreach(req ${ARGN}) + set_property(GLOBAL PROPERTY ${req}_REQUIRED TRUE) + endforeach(req) + endif(WITH_${TYPE}_${NAME}) +endfunction(fastd_module_require) |