diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Modules/BuildMacros.cmake | 87 | ||||
-rw-r--r-- | cmake/Modules/FindLibFec.cmake | 24 | ||||
-rw-r--r-- | cmake/Modules/FindLibRely.cmake | 24 | ||||
-rw-r--r-- | cmake/Modules/FindLibconfig++.cmake | 43 | ||||
-rw-r--r-- | cmake/Modules/FindLibconfig.cmake | 43 | ||||
-rw-r--r-- | cmake/Modules/FindLibhicn.cmake | 2 | ||||
-rw-r--r-- | cmake/Modules/GTestImport.cmake | 7 | ||||
-rw-r--r-- | cmake/Modules/ServiceScript.cmake | 2 |
8 files changed, 212 insertions, 20 deletions
diff --git a/cmake/Modules/BuildMacros.cmake b/cmake/Modules/BuildMacros.cmake index 7119541dd..4c55f32fe 100644 --- a/cmake/Modules/BuildMacros.cmake +++ b/cmake/Modules/BuildMacros.cmake @@ -21,7 +21,7 @@ macro(build_executable exec) cmake_parse_arguments(ARG "NO_INSTALL" "COMPONENT" - "SOURCES;LINK_LIBRARIES;DEPENDS;INCLUDE_DIRS;DEFINITIONS;LINK_FLAGS" + "SOURCES;LINK_LIBRARIES;DEPENDS;INCLUDE_DIRS;DEFINITIONS;COMPILE_OPTIONS;LINK_FLAGS" ${ARGN} ) @@ -48,6 +48,10 @@ macro(build_executable exec) add_dependencies(${exec}-bin ${ARG_DEPENDS}) endif() + if (ARG_COMPILE_OPTIONS) + target_compile_options(${exec}-bin ${ARG_COMPILE_OPTIONS}) + endif() + if(ARG_DEFINITIONS) target_compile_definitions(${exec}-bin PRIVATE ${ARG_DEFINITIONS}) endif() @@ -71,12 +75,17 @@ endmacro() macro(build_library lib) cmake_parse_arguments(ARG - "SHARED;STATIC;MODULE;NO_DEV" + "SHARED;STATIC;NO_DEV" "COMPONENT;" - "SOURCES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS;INCLUDE_DIRS;DEFINITIONS;INSTALL_ROOT_DIR;INSTALL_FULL_PATH_DIR;EMPTY_PREFIX;" + "SOURCES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS;INCLUDE_DIRS;DEFINITIONS;HEADER_ROOT_DIR;LIBRARY_ROOT_DIR;INSTALL_FULL_PATH_DIR;EMPTY_PREFIX;COMPILE_OPTIONS;VERSION" ${ARGN} ) + message(STATUS "Building library ${lib}") + + # Clear target_libs + unset(TARGET_LIBS) + if (ARG_SHARED) list(APPEND TARGET_LIBS ${lib}.shared @@ -91,13 +100,6 @@ macro(build_library lib) add_library(${lib}.static STATIC ${ARG_SOURCES}) endif() - if(ARG_MODULE) - list(APPEND TARGET_LIBS - ${lib}.module - ) - add_library(${lib}.module MODULE ${ARG_SOURCES}) - endif() - if(NOT ARG_COMPONENT) set(ARG_COMPONENT hicn) endif() @@ -135,13 +137,13 @@ macro(build_library lib) endif() if (WIN32) - target_compile_options(${library} PRIVATE) + target_compile_options(${library} PRIVATE ${ARG_COMPILE_OPTIONS}) set_target_properties(${library} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE ) else () - target_compile_options(${library} PRIVATE -Wall) + target_compile_options(${library} PRIVATE -Wall ${ARG_COMPILE_OPTIONS}) set_target_properties(${library} PROPERTIES OUTPUT_NAME ${lib} @@ -164,7 +166,14 @@ macro(build_library lib) ) endif() - set(INSTALL_LIB_PATH ${CMAKE_INSTALL_LIBDIR}) + if(ARG_VERSION) + set_target_properties(${library} + PROPERTIES + VERSION ${ARG_VERSION} + ) + endif() + + set(INSTALL_LIB_PATH "${CMAKE_INSTALL_LIBDIR}/${ARG_LIBRARY_ROOT_DIR}") if (ARG_INSTALL_FULL_PATH_DIR) set(INSTALL_LIB_PATH ${ARG_INSTALL_FULL_PATH_DIR}) @@ -185,8 +194,8 @@ macro(build_library lib) # install headers if(ARG_INSTALL_HEADERS) - if (NOT ARG_INSTALL_ROOT_DIR) - set(ARG_INSTALL_ROOT_DIR "hicn") + if (NOT ARG_HEADER_ROOT_DIR) + set(ARG_HEADER_ROOT_DIR "hicn") endif() list(APPEND local_comps @@ -204,7 +213,7 @@ macro(build_library lib) if ("${dir}" STREQUAL includes) set(dir "") endif() - if ("${dir}" STREQUAL ${ARG_INSTALL_ROOT_DIR}) + if ("${dir}" STREQUAL ${ARG_HEADER_ROOT_DIR}) set(dir "") endif() else() @@ -217,12 +226,56 @@ macro(build_library lib) endif() install( FILES ${file} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ARG_INSTALL_ROOT_DIR}/${dir} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ARG_HEADER_ROOT_DIR}/${dir} COMPONENT ${COMPONENT} ) endforeach() endif() endmacro() +macro (build_module module) + cmake_parse_arguments(ARG + "SHARED;STATIC;NO_DEV" + "COMPONENT;" + "SOURCES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS;INCLUDE_DIRS;DEFINITIONS;HEADER_ROOT_DIR;LIBRARY_ROOT_DIR;INSTALL_FULL_PATH_DIR;EMPTY_PREFIX;COMPILE_OPTIONS;VERSION" + ${ARGN} + ) + + message(STATUS "Building module ${module}") + + build_library(${module} + SHARED + SOURCES ${ARG_SOURCES} + LINK_LIBRARIES ${ARG_LINK_LIBRARIES} + INSTALL_HEADERS ${ARG_INSTALL_HEADERS} + DEPENDS ${ARG_DEPENDS} + COMPONENT lib${LIBTRANSPORT} + INCLUDE_DIRS ${ARG_INCLUDE_DIRS} + HEADER_ROOT_DIR ${ARG_HEADER_ROOT_DIR} + LIBRARY_ROOT_DIR ${ARG_LIBRARY_ROOT_DIR} + INSTALL_FULL_PATH_DIR ${ARG_INSTALL_FULL_PATH_DIR} + DEFINITIONS ${ARG_DEFINITIONS} + EMPTY_PREFIX ${ARG_EMPTY_PREFIX} + COMPILE_OPTIONS ${ARG_COMPILE_OPTIONS} + VERSION ${ARG_VERSION} + ) + + if (${CMAKE_SYSTEM_NAME} MATCHES Darwin) + set(LINK_FLAGS "-Wl,-undefined,dynamic_lookup") + elseif(${CMAKE_SYSTEM_NAME} MATCHES Linux) + set(LINK_FLAGS "-Wl,-unresolved-symbols=ignore-all") + else() + message(FATAL_ERROR "Trying to build module on a not supportd platform. Aborting.") + endif() + + set_target_properties(${module}.shared + PROPERTIES + LINKER_LANGUAGE C + PREFIX "" + LINK_FLAGS ${LINK_FLAGS} + ) + +endmacro(build_module) + include(IosMacros) include(WindowsMacros) diff --git a/cmake/Modules/FindLibFec.cmake b/cmake/Modules/FindLibFec.cmake new file mode 100644 index 000000000..f8b33ad6b --- /dev/null +++ b/cmake/Modules/FindLibFec.cmake @@ -0,0 +1,24 @@ +set(LIBFEC_SEARCH_PATH_LIST + ${LIBFEC_HOME} + $ENV{DEPENDENCIES} + $ENV{LIBFEC_HOME} + /usr/local + /opt + /usr + ) + +find_path(LIBFEC_INCLUDE_DIR fec/version.h + HINTS ${LIBFEC_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the LibFec includes" ) + +find_library(LIBFEC_LIBRARY NAMES fec + HINTS ${LIBFEC_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LibFec libraries" ) + +set(LIBFEC_LIBRARIES ${LIBFEC_LIBRARY}) +set(LIBFEC_INCLUDE_DIRS ${LIBFEC_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibFec DEFAULT_MSG LIBFEC_LIBRARY LIBFEC_INCLUDE_DIR)
\ No newline at end of file diff --git a/cmake/Modules/FindLibRely.cmake b/cmake/Modules/FindLibRely.cmake new file mode 100644 index 000000000..4b8960041 --- /dev/null +++ b/cmake/Modules/FindLibRely.cmake @@ -0,0 +1,24 @@ +set(LIBRELY_SEARCH_PATH_LIST + ${LIBRELY_HOME} + $ENV{DEPENDENCIES} + $ENV{LIBRELY_HOME} + /usr/local + /opt + /usr + ) + +find_path(LIBRELY_INCLUDE_DIR rely/version.hpp + HINTS ${LIBRELY_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the LibRely includes" ) + +find_library(LIBRELY_LIBRARY NAMES rely + HINTS ${LIBRELY_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LibRely libraries" ) + +set(LIBRELY_LIBRARIES ${LIBRELY_LIBRARY}) +set(LIBRELY_INCLUDE_DIRS ${LIBRELY_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibRely DEFAULT_MSG LIBRELY_LIBRARY LIBRELY_INCLUDE_DIR)
\ No newline at end of file diff --git a/cmake/Modules/FindLibconfig++.cmake b/cmake/Modules/FindLibconfig++.cmake new file mode 100644 index 000000000..865f75078 --- /dev/null +++ b/cmake/Modules/FindLibconfig++.cmake @@ -0,0 +1,43 @@ +set(LIBCONFIG_SEARCH_PATH_LIST + ${LIBCONFIG_HOME} + $ENV{LIBCONFIG_HOME} + /usr/local + /opt + /usr +) + +find_path(LIBCONFIG_INCLUDE_DIR libconfig.h++ + HINTS ${LIBCONFIG_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the libconfig include" +) + +if (WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(LIBCONFIG_LIBRARY NAMES libconfig.lib + HINTS ${LIBCONFIG_SEARCH_PATH_LIST} + PATH_SUFFIXES lib/x64 + DOC "Find the libconfig libraries" + ) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(LIBCONFIG_LIBRARY NAMES libconfig.lib + HINTS ${LIBCONFIG_SEARCH_PATH_LIST} + PATH_SUFFIXES lib/x32 + DOC "Find the libconfig libraries" + ) + endif() +else() + find_library(LIBCONFIG_CPP_LIBRARY NAMES config++ + HINTS ${LIBCONFIG_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the libconfig++ libraries" + ) +endif() + +set(LIBCONFIG_CPP_LIBRARIES ${LIBCONFIG_CPP_LIBRARY}) +set(LIBCONFIG_INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libconfig++ LIBCONFIG_CPP_LIBRARIES LIBCONFIG_INCLUDE_DIRS) + +mark_as_advanced(LIBCONFIG_CPP_LIBRARIES LIBCONFIG_INCLUDE_DIRS) diff --git a/cmake/Modules/FindLibconfig.cmake b/cmake/Modules/FindLibconfig.cmake new file mode 100644 index 000000000..55d2a0fad --- /dev/null +++ b/cmake/Modules/FindLibconfig.cmake @@ -0,0 +1,43 @@ +set(LIBCONFIG_SEARCH_PATH_LIST + ${LIBCONFIG_HOME} + $ENV{LIBCONFIG_HOME} + /usr/local + /opt + /usr +) + +find_path(LIBCONFIG_INCLUDE_DIR libconfig.h + HINTS ${LIBCONFIG_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the libconfig include" +) + +if (WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(LIBCONFIG_LIBRARY NAMES libconfig.lib + HINTS ${LIBCONFIG_SEARCH_PATH_LIST} + PATH_SUFFIXES lib/x64 + DOC "Find the libconfig libraries" + ) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(LIBCONFIG_LIBRARY NAMES libconfig.lib + HINTS ${LIBCONFIG_SEARCH_PATH_LIST} + PATH_SUFFIXES lib/x32 + DOC "Find the libconfig libraries" + ) + endif() +else() + find_library(LIBCONFIG_LIBRARY NAMES config + HINTS ${LIBCONFIG_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the libconfig libraries" + ) +endif() + +set(LIBCONFIG_LIBRARIES ${LIBCONFIG_LIBRARY}) +set(LIBCONFIG_INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libconfig LIBCONFIG_LIBRARIES LIBCONFIG_INCLUDE_DIRS) + +mark_as_advanced(LIBCONFIG_LIBRARIES LIBCONFIG_INCLUDE_DIRS) diff --git a/cmake/Modules/FindLibhicn.cmake b/cmake/Modules/FindLibhicn.cmake index 38775be6a..5f241a6cd 100644 --- a/cmake/Modules/FindLibhicn.cmake +++ b/cmake/Modules/FindLibhicn.cmake @@ -44,7 +44,7 @@ find_library(HICN_LIBRARY NAMES hicn set(HICN_LIBRARIES ${HICN_LIBRARY}) if (${CMAKE_SYSTEM_NAME} STREQUAL "Android") -set(HICN_LIBRARIES ${HICN_LIBRARIES} log) + set(HICN_LIBRARIES ${HICN_LIBRARIES} log) endif() set(HICN_INCLUDE_DIRS ${HICN_INCLUDE_DIR}) diff --git a/cmake/Modules/GTestImport.cmake b/cmake/Modules/GTestImport.cmake index 4e2e18dc9..d9d182578 100644 --- a/cmake/Modules/GTestImport.cmake +++ b/cmake/Modules/GTestImport.cmake @@ -18,6 +18,11 @@ include(ExternalProject) ExternalProject_Add(gtest URL https://github.com/google/googletest/archive/v1.10.x.zip PREFIX ${CMAKE_BINARY_DIR}/gtest + BUILD_BYPRODUCTS + ${CMAKE_BINARY_DIR}/gtest/src/gtest-build/lib/libgmock_main.a + ${CMAKE_BINARY_DIR}/gtest/src/gtest-build/lib/libgmock.a + ${CMAKE_BINARY_DIR}/gtest/src/gtest-build/lib/libgtest_main.a + ${CMAKE_BINARY_DIR}/gtest/src/gtest-build/lib/libgtest.a INSTALL_COMMAND "" ) @@ -37,4 +42,4 @@ macro(add_test_internal test) endif() endmacro(add_test_internal) -enable_testing()
\ No newline at end of file +enable_testing() diff --git a/cmake/Modules/ServiceScript.cmake b/cmake/Modules/ServiceScript.cmake index 110aa816b..8e7056a5a 100644 --- a/cmake/Modules/ServiceScript.cmake +++ b/cmake/Modules/ServiceScript.cmake @@ -39,4 +39,4 @@ cmake_parse_arguments(ARG if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") install (FILES ${script} DESTINATION ${SYSTEMD_SERVICE_FOLDER} COMPONENT ${ARG_COMPONENT}) endif() -endmacro(install_service_script)
\ No newline at end of file +endmacro(install_service_script) |