mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Adjust CMakeLists to make dependency downloading optional
This commit is contained in:
parent
00549e0ec5
commit
3afc76dbaa
7 changed files with 127 additions and 94 deletions
120
CMakeLists.txt
120
CMakeLists.txt
|
@ -31,26 +31,7 @@ add_project_meta(META_FILES_TO_INCLUDE)
|
||||||
#
|
#
|
||||||
# LMDB
|
# LMDB
|
||||||
#
|
#
|
||||||
if(APPVEYOR_BUILD)
|
include(LMDB)
|
||||||
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()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Discover Qt dependencies.
|
# Discover Qt dependencies.
|
||||||
|
@ -76,10 +57,10 @@ endif(Qt5Widgets_FOUND)
|
||||||
# Set up compiler flags.
|
# Set up compiler flags.
|
||||||
#
|
#
|
||||||
set(CMAKE_C_COMPILER gcc)
|
set(CMAKE_C_COMPILER gcc)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
include(CompilerFlags)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
|
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})
|
set(BUILD_USER $ENV{USER})
|
||||||
configure_file(cmake/version.hpp config/version.hpp)
|
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.
|
# Declare source and header files.
|
||||||
|
@ -216,30 +172,46 @@ set(SRC_FILES
|
||||||
src/main.cc
|
src/main.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ExternalProject dependencies
|
||||||
|
set(EXTERNAL_PROJECT_DEPS "")
|
||||||
|
|
||||||
#
|
#
|
||||||
# matrix-structs
|
# matrix-structs
|
||||||
#
|
#
|
||||||
include(MatrixStructs)
|
find_library(MATRIX_STRUCTS_LIBRARY
|
||||||
include_directories(${MATRIX_STRUCTS_INCLUDE_DIRS})
|
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)
|
if(NOT TWEENY_INCLUDE_DIR)
|
||||||
include_directories(${TWEENY_INCLUDE_DIRS})
|
include(Tweeny)
|
||||||
|
set(EXTERNAL_PROJECT_DEPS ${EXTERNAL_PROJECT_DEPS} Tweeny)
|
||||||
|
endif()
|
||||||
|
include_directories(SYSTEM ${TWEENY_INCLUDE_DIR})
|
||||||
|
|
||||||
#
|
#
|
||||||
# lmdbxx
|
# lmdbxx
|
||||||
#
|
#
|
||||||
include(LMDBXX)
|
if(NOT LMDBXX_INCLUDE_DIR)
|
||||||
include_directories(${LMDBXX_INCLUDE_DIRS})
|
include(LMDBXX)
|
||||||
|
set(EXTERNAL_PROJECT_DEPS ${EXTERNAL_PROJECT_DEPS} lmdbxx)
|
||||||
|
endif()
|
||||||
|
include_directories(SYSTEM ${LMDBXX_INCLUDE_DIR})
|
||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
include_directories(include/ui)
|
include_directories(include/ui)
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/config)
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/config)
|
||||||
|
|
||||||
include_directories(${LMDB_INCLUDE_DIR})
|
|
||||||
|
|
||||||
qt5_wrap_cpp(MOC_HEADERS
|
qt5_wrap_cpp(MOC_HEADERS
|
||||||
# Dialogs
|
# Dialogs
|
||||||
include/dialogs/CreateRoom.h
|
include/dialogs/CreateRoom.h
|
||||||
|
@ -314,27 +286,14 @@ qt5_wrap_cpp(MOC_HEADERS
|
||||||
#
|
#
|
||||||
# Bundle translations.
|
# 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})
|
set(COMMON_LIBS
|
||||||
add_custom_target(LANG_QRC ALL DEPENDS ${QM_SRC})
|
${MATRIX_STRUCTS_LIBRARY}
|
||||||
|
Qt5::Widgets
|
||||||
# Generate a qrc file for the translations
|
Qt5::Network
|
||||||
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
Qt5::Concurrent)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
if(APPVEYOR_BUILD)
|
if(APPVEYOR_BUILD)
|
||||||
set(NHEKO_LIBS ${COMMON_LIBS} lmdb)
|
set(NHEKO_LIBS ${COMMON_LIBS} lmdb)
|
||||||
|
@ -342,7 +301,12 @@ else()
|
||||||
set(NHEKO_LIBS ${COMMON_LIBS} ${LMDB_LIBRARY})
|
set(NHEKO_LIBS ${COMMON_LIBS} ${LMDB_LIBRARY})
|
||||||
endif()
|
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)
|
if(APPLE)
|
||||||
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
|
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
|
||||||
|
@ -355,7 +319,9 @@ else()
|
||||||
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::Multimedia)
|
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::Multimedia)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_dependencies(nheko MatrixStructs Tweeny lmdbxx)
|
if(EXTERNAL_PROJECT_DEPS)
|
||||||
|
add_dependencies(nheko ${EXTERNAL_PROJECT_DEPS})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
install (TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
install (TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
|
|
25
cmake/CompilerFlags.cmake
Normal file
25
cmake/CompilerFlags.cmake
Normal file
|
@ -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()
|
29
cmake/LMDB.cmake
Normal file
29
cmake/LMDB.cmake
Normal file
|
@ -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(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/.third-party)
|
||||||
set(LMDBXX_ROOT ${THIRD_PARTY_ROOT}/lmdbxx)
|
set(LMDBXX_ROOT ${THIRD_PARTY_ROOT}/lmdbxx)
|
||||||
|
|
||||||
set(LMDBXX_INCLUDE_DIRS ${LMDBXX_ROOT})
|
set(LMDBXX_INCLUDE_DIR ${LMDBXX_ROOT})
|
||||||
|
|
||||||
ExternalProject_Add(
|
ExternalProject_Add(
|
||||||
lmdbxx
|
lmdbxx
|
||||||
|
@ -21,5 +21,3 @@ ExternalProject_Add(
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(SYSTEM ${LMDBXX_ROOT})
|
|
||||||
|
|
|
@ -6,12 +6,10 @@ include(ExternalProject)
|
||||||
|
|
||||||
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/.third-party)
|
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/.third-party)
|
||||||
set(MATRIX_STRUCTS_ROOT ${THIRD_PARTY_ROOT}/matrix_structs)
|
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)
|
link_directories(${MATRIX_STRUCTS_ROOT})
|
||||||
|
|
||||||
include_directories(SYSTEM ${MATRIX_STRUCTS_ROOT}/deps)
|
|
||||||
include_directories(SYSTEM ${MATRIX_STRUCTS_ROOT}/include)
|
|
||||||
link_directories(${MATRIX_STRUCTS_ROOT}/lib)
|
|
||||||
|
|
||||||
set(WINDOWS_FLAGS "")
|
set(WINDOWS_FLAGS "")
|
||||||
|
|
||||||
|
@ -23,17 +21,13 @@ ExternalProject_Add(
|
||||||
MatrixStructs
|
MatrixStructs
|
||||||
|
|
||||||
GIT_REPOSITORY https://github.com/mujx/matrix-structs
|
GIT_REPOSITORY https://github.com/mujx/matrix-structs
|
||||||
GIT_TAG 45e2671d9e5a5de46834c834e282da006f1689a0
|
GIT_TAG 91bb2b85a75d664007ef81aeb500d35268425922
|
||||||
|
|
||||||
BUILD_IN_SOURCE 1
|
BUILD_IN_SOURCE 1
|
||||||
SOURCE_DIR ${MATRIX_STRUCTS_ROOT}
|
SOURCE_DIR ${MATRIX_STRUCTS_ROOT}
|
||||||
CONFIGURE_COMMAND ${CMAKE_COMMAND}
|
CONFIGURE_COMMAND ${CMAKE_COMMAND}
|
||||||
-DCMAKE_BUILD_TYPE=Release ${MATRIX_STRUCTS_ROOT}
|
-DCMAKE_BUILD_TYPE=Release ${MATRIX_STRUCTS_ROOT}
|
||||||
-DCMAKE_INSTALL_PREFIX=${MATRIX_STRUCTS_ROOT}
|
|
||||||
${WINDOWS_FLAGS}
|
${WINDOWS_FLAGS}
|
||||||
BUILD_COMMAND ${CMAKE_COMMAND} --build ${MATRIX_STRUCTS_ROOT} --config Release
|
BUILD_COMMAND ${CMAKE_COMMAND} --build ${MATRIX_STRUCTS_ROOT} --config Release
|
||||||
INSTALL_COMMAND ${CMAKE_COMMAND}
|
INSTALL_COMMAND ""
|
||||||
--build ${MATRIX_STRUCTS_ROOT}
|
|
||||||
--config Release
|
|
||||||
--target install
|
|
||||||
)
|
)
|
||||||
|
|
23
cmake/Translations.cmake
Normal file
23
cmake/Translations.cmake
Normal file
|
@ -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(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/.third-party)
|
||||||
set(TWEENY_ROOT ${THIRD_PARTY_ROOT}/tweeny)
|
set(TWEENY_ROOT ${THIRD_PARTY_ROOT}/tweeny)
|
||||||
|
|
||||||
set(TWEENY_INCLUDE_DIRS ${TWEENY_ROOT}/include)
|
set(TWEENY_INCLUDE_DIR ${TWEENY_ROOT}/include)
|
||||||
|
|
||||||
ExternalProject_Add(
|
ExternalProject_Add(
|
||||||
Tweeny
|
Tweeny
|
||||||
|
@ -21,5 +21,3 @@ ExternalProject_Add(
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(SYSTEM ${TWEENY_ROOT}/include)
|
|
||||||
|
|
Loading…
Reference in a new issue