Adjust CMakeLists to make dependency downloading optional

remotes/origin/HEAD
Konstantinos Sideris 7 years ago
parent 00549e0ec5
commit 3afc76dbaa
  1. 120
      CMakeLists.txt
  2. 25
      cmake/CompilerFlags.cmake
  3. 29
      cmake/LMDB.cmake
  4. 4
      cmake/LMDBXX.cmake
  5. 16
      cmake/MatrixStructs.cmake
  6. 23
      cmake/Translations.cmake
  7. 4
      cmake/Tweeny.cmake

@ -31,26 +31,7 @@ add_project_meta(META_FILES_TO_INCLUDE)
#
# LMDB
#
if(APPVEYOR_BUILD)
set(LMDB_VERSION "LMDB_0.9.21")
set(NTDLIB "C:/WINDDK/7600.16385.1/lib/win7/amd64/ntdll.lib")
execute_process(
COMMAND git clone --depth=1 --branch ${LMDB_VERSION} https://github.com/LMDB/lmdb)
set(LMDB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb)
add_library(lmdb
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/lmdb.h
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/mdb.c
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/midl.h
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/midl.c)
else()
find_path (LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "$ENV{LMDB_DIR}/include")
find_library (LMDB_LIBRARY NAMES lmdb PATHS "$ENV{LMDB_DIR}/lib" )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LMDB DEFAULT_MSG LMDB_INCLUDE_DIR LMDB_LIBRARY)
endif()
include(LMDB)
#
# Discover Qt dependencies.
@ -76,10 +57,10 @@ endif(Qt5Widgets_FOUND)
# Set up compiler flags.
#
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(CompilerFlags)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
@ -109,31 +90,6 @@ cmake_host_system_information(RESULT BUILD_HOST QUERY HOSTNAME)
set(BUILD_USER $ENV{USER})
configure_file(cmake/version.hpp config/version.hpp)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wall \
-Wextra \
-Werror \
-pipe \
-pedantic \
-Wunreachable-code")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always" )
endif()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always" )
endif()
endif()
if(NOT APPLE AND NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
#
# Declare source and header files.
@ -216,30 +172,46 @@ set(SRC_FILES
src/main.cc
)
# ExternalProject dependencies
set(EXTERNAL_PROJECT_DEPS "")
#
# matrix-structs
#
include(MatrixStructs)
include_directories(${MATRIX_STRUCTS_INCLUDE_DIRS})
find_library(MATRIX_STRUCTS_LIBRARY
NAMES matrix_structs
PATHS ${MATRIX_STRUCTS_ROOT}
${MATRIX_STRUCTS_ROOT}/lib
${MATRIX_STRUCTS_ROOT}/lib/static)
if(NOT MATRIX_STRUCTS_LIBRARY)
include(MatrixStructs)
set(EXTERNAL_PROJECT_DEPS ${EXTERNAL_PROJECT_DEPS} MatrixStructs)
endif()
include_directories(SYSTEM ${MATRIX_STRUCTS_INCLUDE_DIR})
#
# libtweeny
# tweeny
#
include(Tweeny)
include_directories(${TWEENY_INCLUDE_DIRS})
if(NOT TWEENY_INCLUDE_DIR)
include(Tweeny)
set(EXTERNAL_PROJECT_DEPS ${EXTERNAL_PROJECT_DEPS} Tweeny)
endif()
include_directories(SYSTEM ${TWEENY_INCLUDE_DIR})
#
# lmdbxx
#
include(LMDBXX)
include_directories(${LMDBXX_INCLUDE_DIRS})
if(NOT LMDBXX_INCLUDE_DIR)
include(LMDBXX)
set(EXTERNAL_PROJECT_DEPS ${EXTERNAL_PROJECT_DEPS} lmdbxx)
endif()
include_directories(SYSTEM ${LMDBXX_INCLUDE_DIR})
include_directories(include)
include_directories(include/ui)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/config)
include_directories(${LMDB_INCLUDE_DIR})
qt5_wrap_cpp(MOC_HEADERS
# Dialogs
include/dialogs/CreateRoom.h
@ -314,27 +286,14 @@ qt5_wrap_cpp(MOC_HEADERS
#
# Bundle translations.
#
FILE(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
include(Translations)
set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC})
qt5_add_translation(QM_SRC ${LANG_TS_SRC})
add_custom_target(LANG_QRC ALL DEPENDS ${QM_SRC})
# Generate a qrc file for the translations
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
if(NOT EXISTS ${_qrc})
file(WRITE ${_qrc} "<RCC> <qresource prefix=\"/translations\">")
foreach(_lang ${QM_SRC})
get_filename_component(_filename ${_lang} NAME)
file(APPEND ${_qrc} "<file>${_filename}</file>")
endforeach(_lang)
file(APPEND ${_qrc} "</qresource> </RCC>")
endif()
qt5_add_resources(LANG_QRC ${_qrc})
qt5_add_resources(QRC resources/res.qrc)
set(COMMON_LIBS matrix_structs Qt5::Widgets Qt5::Network Qt5::Concurrent)
set(COMMON_LIBS
${MATRIX_STRUCTS_LIBRARY}
Qt5::Widgets
Qt5::Network
Qt5::Concurrent)
if(APPVEYOR_BUILD)
set(NHEKO_LIBS ${COMMON_LIBS} lmdb)
@ -342,7 +301,12 @@ else()
set(NHEKO_LIBS ${COMMON_LIBS} ${LMDB_LIBRARY})
endif()
set (NHEKO_DEPS ${SRC_FILES} ${UI_HEADERS} ${MOC_HEADERS} ${QRC} ${LANG_QRC} ${QM_SRC} ${META_FILES_TO_INCLUDE})
set(NHEKO_DEPS
${SRC_FILES}
${UI_HEADERS}
${MOC_HEADERS}
${TRANSLATION_DEPS}
${META_FILES_TO_INCLUDE})
if(APPLE)
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
@ -355,7 +319,9 @@ else()
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::Multimedia)
endif()
add_dependencies(nheko MatrixStructs Tweeny lmdbxx)
if(EXTERNAL_PROJECT_DEPS)
add_dependencies(nheko ${EXTERNAL_PROJECT_DEPS})
endif()
if(UNIX AND NOT APPLE)
install (TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

@ -0,0 +1,25 @@
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wall \
-Wextra \
-Werror \
-pipe \
-pedantic \
-Wunreachable-code")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always" )
endif()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always" )
endif()
endif()
if(NOT APPLE AND NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()

@ -0,0 +1,29 @@
#
# Find the lmdb library & include dir.
# Build lmdb on Appveyor.
#
if(APPVEYOR_BUILD)
set(LMDB_VERSION "LMDB_0.9.21")
set(NTDLIB "C:/WINDDK/7600.16385.1/lib/win7/amd64/ntdll.lib")
execute_process(
COMMAND git clone --depth=1 --branch ${LMDB_VERSION} https://github.com/LMDB/lmdb)
set(LMDB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb)
add_library(lmdb
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/lmdb.h
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/mdb.c
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/midl.h
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/midl.c)
set(LMDB_LIBRARY lmdb)
else()
find_path (LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "$ENV{LMDB_DIR}/include")
find_library (LMDB_LIBRARY NAMES lmdb PATHS "$ENV{LMDB_DIR}/lib" )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LMDB DEFAULT_MSG LMDB_INCLUDE_DIR LMDB_LIBRARY)
endif()
include_directories(${LMDB_INCLUDE_DIR})

@ -7,7 +7,7 @@ include(ExternalProject)
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/.third-party)
set(LMDBXX_ROOT ${THIRD_PARTY_ROOT}/lmdbxx)
set(LMDBXX_INCLUDE_DIRS ${LMDBXX_ROOT})
set(LMDBXX_INCLUDE_DIR ${LMDBXX_ROOT})
ExternalProject_Add(
lmdbxx
@ -21,5 +21,3 @@ ExternalProject_Add(
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
include_directories(SYSTEM ${LMDBXX_ROOT})

@ -6,12 +6,10 @@ include(ExternalProject)
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/.third-party)
set(MATRIX_STRUCTS_ROOT ${THIRD_PARTY_ROOT}/matrix_structs)
set(MATRIX_STRUCTS_INCLUDE_DIR ${MATRIX_STRUCTS_ROOT}/include)
set(MATRIX_STRUCTS_LIBRARY matrix_structs)
set(MATRIX_STRUCTS_INCLUDE_DIRS ${MATRIX_STRUCTS_ROOT}/deps)
include_directories(SYSTEM ${MATRIX_STRUCTS_ROOT}/deps)
include_directories(SYSTEM ${MATRIX_STRUCTS_ROOT}/include)
link_directories(${MATRIX_STRUCTS_ROOT}/lib)
link_directories(${MATRIX_STRUCTS_ROOT})
set(WINDOWS_FLAGS "")
@ -23,17 +21,13 @@ ExternalProject_Add(
MatrixStructs
GIT_REPOSITORY https://github.com/mujx/matrix-structs
GIT_TAG 45e2671d9e5a5de46834c834e282da006f1689a0
GIT_TAG 91bb2b85a75d664007ef81aeb500d35268425922
BUILD_IN_SOURCE 1
SOURCE_DIR ${MATRIX_STRUCTS_ROOT}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Release ${MATRIX_STRUCTS_ROOT}
-DCMAKE_INSTALL_PREFIX=${MATRIX_STRUCTS_ROOT}
${WINDOWS_FLAGS}
BUILD_COMMAND ${CMAKE_COMMAND} --build ${MATRIX_STRUCTS_ROOT} --config Release
INSTALL_COMMAND ${CMAKE_COMMAND}
--build ${MATRIX_STRUCTS_ROOT}
--config Release
--target install
INSTALL_COMMAND ""
)

@ -0,0 +1,23 @@
#
# Generate the translation resource file
#
FILE(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
qt5_add_translation(QM_SRC ${LANG_TS_SRC})
add_custom_target(LANG_QRC ALL DEPENDS ${QM_SRC})
# Generate a qrc file for the translations
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
if(NOT EXISTS ${_qrc})
file(WRITE ${_qrc} "<RCC> <qresource prefix=\"/translations\">")
foreach(_lang ${QM_SRC})
get_filename_component(_filename ${_lang} NAME)
file(APPEND ${_qrc} "<file>${_filename}</file>")
endforeach(_lang)
file(APPEND ${_qrc} "</qresource> </RCC>")
endif()
qt5_add_resources(LANG_QRC ${_qrc})
qt5_add_resources(QRC resources/res.qrc)

@ -7,7 +7,7 @@ include(ExternalProject)
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/.third-party)
set(TWEENY_ROOT ${THIRD_PARTY_ROOT}/tweeny)
set(TWEENY_INCLUDE_DIRS ${TWEENY_ROOT}/include)
set(TWEENY_INCLUDE_DIR ${TWEENY_ROOT}/include)
ExternalProject_Add(
Tweeny
@ -21,5 +21,3 @@ ExternalProject_Add(
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
include_directories(SYSTEM ${TWEENY_ROOT}/include)

Loading…
Cancel
Save