Merge branch 'cmake_remove_libs' into 'master'

cmake: Remove the intermediate static libs

See merge request !7
This commit is contained in:
louiz
2017-03-10 11:24:27 +01:00
2 changed files with 65 additions and 79 deletions
+56 -53
View File
@@ -106,22 +106,15 @@ if(LITESQL_FOUND)
"biboudb" "biboudb"
LITESQL_GENERATED_SOURCES) LITESQL_GENERATED_SOURCES)
add_library(database STATIC src/database/database.cpp set(source_database src/database/database.cpp ${LITESQL_GENERATED_SOURCES})
${LITESQL_GENERATED_SOURCES})
target_link_libraries(database ${LITESQL_LIBRARIES} utils)
if(BOTAN_FOUND)
target_link_libraries(database ${BOTAN_LIBRARIES})
endif()
set(USE_DATABASE TRUE) set(USE_DATABASE TRUE)
else()
set(source_database)
endif() endif()
add_subdirectory("louloulibs") add_subdirectory("louloulibs")
include_directories("louloulibs") include_directories("louloulibs")
include_directories(${EXPAT_INCLUDE_DIRS})
include_directories(${ICONV_INCLUDE_DIRS})
include_directories(${LIBUUID_INCLUDE_DIRS})
# If they are found in louloulibs CMakeLists.txt, we inherite these values # If they are found in louloulibs CMakeLists.txt, we inherite these values
if(SYSTEMD_FOUND) if(SYSTEMD_FOUND)
include_directories(${SYSTEMD_INCLUDE_DIRS}) include_directories(${SYSTEMD_INCLUDE_DIRS})
@@ -138,85 +131,95 @@ endif()
# #
file(GLOB source_src_utils file(GLOB source_src_utils
src/utils/*.[hc]pp) src/utils/*.[hc]pp)
# Todo, switch to target_sources(utils) when we go cmake >=3.1 only
add_library(src_utils STATIC ${source_src_utils})
target_link_libraries(src_utils logger config)
if(USE_DATABASE)
target_link_libraries(src_utils database)
endif()
# #
## irclib ## irclib
# #
file(GLOB source_irc file(GLOB source_irc
src/irc/*.[hc]pp) src/irc/*.[hc]pp)
add_library(irc STATIC ${source_irc})
target_link_libraries(irc network utils logger)
# #
## xmpp ## xmpp
# #
file(GLOB source_xmpp file(GLOB source_xmpp
src/xmpp/*.[hc]pp) src/xmpp/*.[hc]pp)
add_library(xmpp STATIC ${source_xmpp})
target_link_libraries(xmpp xmpplib bridge network utils src_utils logger)
if(USE_DATABASE)
target_link_libraries(xmpp database)
target_link_libraries(irc database)
endif()
# #
## identd ## identd
# #
file(GLOB source_identd file(GLOB source_identd
src/identd/*.[hc]pp) src/identd/*.[hc]pp)
add_library(identd STATIC ${source_identd})
target_link_libraries(identd bridge network utils src_utils logger)
# #
## bridge ## bridge
# #
file(GLOB source_bridge file(GLOB source_bridge
src/bridge/*.[hc]pp) src/bridge/*.[hc]pp)
add_library(bridge STATIC ${source_bridge})
target_link_libraries(bridge xmpp irc utils logger)
# #
## Main executable ## Main executable
# #
add_executable(${PROJECT_NAME} src/main.cpp) add_executable(${PROJECT_NAME} src/main.cpp
target_link_libraries(${PROJECT_NAME} ${source_utils}
xmpp ${source_config}
irc ${source_logger}
bridge ${source_network}
utils ${source_xmpplib}
src_utils ${source_xmpp}
identd ${source_src_utils}
config) ${source_bridge}
if(SYSTEMD_FOUND) ${source_irc}
target_link_libraries(xmpp ${SYSTEMD_LIBRARIES}) ${source_identd}
endif() ${source_database})
# #
## Tests ## Tests
# #
file(GLOB source_tests file(GLOB source_tests
tests/*.cpp) tests/*.cpp)
add_executable(test_suite EXCLUDE_FROM_ALL add_executable(test_suite EXCLUDE_FROM_ALL ${source_tests}
${source_tests}) ${source_utils}
${source_config}
${source_logger}
${source_network}
${source_xmpplib}
${source_xmpp}
${source_src_utils}
${source_bridge}
${source_irc}
${source_identd}
${source_database})
target_link_libraries(${PROJECT_NAME}
${EXPAT_LIBRARIES}
${LIBUUID_LIBRARIES}
${EXPAT_LIBRARIES})
target_link_libraries(test_suite target_link_libraries(test_suite
xmpplib ${EXPAT_LIBRARIES}
xmpp ${LIBUUID_LIBRARIES}
irc ${EXPAT_LIBRARIES})
bridge if(SYSTEMD_FOUND)
utils target_link_libraries(${PROJECT_NAME} ${SYSTEMD_LIBRARIES})
config target_link_libraries(test_suite ${SYSTEMD_LIBRARIES})
logger endif()
network) if(BOTAN_FOUND)
target_link_libraries(${PROJECT_NAME} ${BOTAN_LIBRARIES})
target_link_libraries(test_suite ${BOTAN_LIBRARIES})
elseif(GCRYPT_FOUND)
target_link_libraries(${PROJECT_NAME} ${GCRYPT_LIBRARIES})
target_link_libraries(test_suite ${GCRYPT_LIBRARIES})
endif()
if(UDNS_FOUND)
target_link_libraries(${PROJECT_NAME} ${UDNS_LIBRARIES})
target_link_libraries(test_suite ${UDNS_LIBRARIES})
endif()
if(LIBIDN_FOUND)
target_link_libraries(${PROJECT_NAME} ${LIBIDN_LIBRARIES})
target_link_libraries(test_suite ${LIBIDN_LIBRARIES})
endif()
if(USE_DATABASE) if(USE_DATABASE)
target_link_libraries(test_suite target_link_libraries(${PROJECT_NAME} ${LITESQL_LIBRARIES})
database) target_link_libraries(test_suite ${LITESQL_LIBRARIES})
endif() endif()
# Define a __FILENAME__ macro with the relative path (from the base project directory) # Define a __FILENAME__ macro with the relative path (from the base project directory)
+9 -26
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 3.0)
set(${PROJECT_NAME}_VERSION_MAJOR 1) set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 0) set(${PROJECT_NAME}_VERSION_MINOR 0)
@@ -51,8 +51,11 @@ include_directories(${ICONV_INCLUDE_DIRS})
include_directories(${LIBUUID_INCLUDE_DIRS}) include_directories(${LIBUUID_INCLUDE_DIRS})
set(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIRS} PARENT_SCOPE) set(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIRS} PARENT_SCOPE)
set(EXPAT_LIBRARIES ${EXPAT_LIBRARIES} PARENT_SCOPE)
set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIRS} PARENT_SCOPE) set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIRS} PARENT_SCOPE)
set(ICONV_LIBRARIES ${ICONV_LIBRARIES} PARENT_SCOPE)
set(LIBUUID_INCLUDE_DIRS ${LIBUUID_INCLUDE_DIRS} PARENT_SCOPE) set(LIBUUID_INCLUDE_DIRS ${LIBUUID_INCLUDE_DIRS} PARENT_SCOPE)
set(LIBUUID_LIBRARIES ${LIBUUID_LIBRARIES} PARENT_SCOPE)
if(LIBIDN_FOUND) if(LIBIDN_FOUND)
include_directories(${LIBIDN_INCLUDE_DIRS}) include_directories(${LIBIDN_INCLUDE_DIRS})
@@ -99,55 +102,35 @@ endif()
# #
file(GLOB source_utils file(GLOB source_utils
utils/*.[hc]pp) utils/*.[hc]pp)
add_library(utils STATIC ${source_utils}) set(source_utils ${source_utils} PARENT_SCOPE)
target_link_libraries(utils ${ICONV_LIBRARIES})
# #
## config ## config
# #
file(GLOB source_config file(GLOB source_config
config/*.[hc]pp) config/*.[hc]pp)
add_library(config STATIC ${source_config}) set(source_config ${source_config} PARENT_SCOPE)
# #
## logger ## logger
# #
file(GLOB source_logger file(GLOB source_logger
logger/*.[hc]pp) logger/*.[hc]pp)
add_library(logger STATIC ${source_logger}) set(source_logger ${source_logger} PARENT_SCOPE)
target_link_libraries(logger config)
# #
## network ## network
# #
file(GLOB source_network file(GLOB source_network
network/*.[hc]pp) network/*.[hc]pp)
add_library(network STATIC ${source_network}) set(source_network ${source_network} PARENT_SCOPE)
target_link_libraries(network logger)
if(BOTAN_FOUND)
target_link_libraries(network ${BOTAN_LIBRARIES})
elseif(GCRYPT_FOUND)
target_link_libraries(network ${GCRYPT_LIBRARIES})
endif()
if(UDNS_FOUND)
target_link_libraries(network ${UDNS_LIBRARIES})
endif()
# #
## xmpplib ## xmpplib
# #
file(GLOB source_xmpplib file(GLOB source_xmpplib
xmpp/*.[hc]pp) xmpp/*.[hc]pp)
add_library(xmpplib STATIC ${source_xmpplib}) set(source_xmpplib ${source_xmpplib} PARENT_SCOPE)
target_link_libraries(xmpplib network utils logger
${EXPAT_LIBRARIES}
${LIBUUID_LIBRARIES})
if(LIBIDN_FOUND)
target_link_libraries(xmpplib ${LIBIDN_LIBRARIES})
endif()
if(SYSTEMD_FOUND)
target_link_libraries(xmpplib ${SYSTEMD_LIBRARIES})
endif()
# Define a __FILENAME__ macro with the relative path (from the base project directory) # Define a __FILENAME__ macro with the relative path (from the base project directory)
# of each source file # of each source file