diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-03-29 09:59:04 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-03-29 09:59:04 +0300 |
commit | 3afc76dbaa8cb3f78516f1d1df0815cdc06ddb93 (patch) | |
tree | d57a3ba743d5ec2f62f7af632ce411919c4858a9 /cmake | |
parent | Use -std=c++11 on matrix structs (diff) | |
download | nheko-3afc76dbaa8cb3f78516f1d1df0815cdc06ddb93.tar.xz |
Adjust CMakeLists to make dependency downloading optional
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/CompilerFlags.cmake | 25 | ||||
-rw-r--r-- | cmake/LMDB.cmake | 29 | ||||
-rw-r--r-- | cmake/LMDBXX.cmake | 4 | ||||
-rw-r--r-- | cmake/MatrixStructs.cmake | 16 | ||||
-rw-r--r-- | cmake/Translations.cmake | 23 | ||||
-rw-r--r-- | cmake/Tweeny.cmake | 4 |
6 files changed, 84 insertions, 17 deletions
diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake new file mode 100644 index 00000000..2aa92e54 --- /dev/null +++ b/cmake/CompilerFlags.cmake @@ -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() diff --git a/cmake/LMDB.cmake b/cmake/LMDB.cmake new file mode 100644 index 00000000..2d8184de --- /dev/null +++ b/cmake/LMDB.cmake @@ -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}) diff --git a/cmake/LMDBXX.cmake b/cmake/LMDBXX.cmake index 502d6b6c..3b9817d9 100644 --- a/cmake/LMDBXX.cmake +++ b/cmake/LMDBXX.cmake @@ -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}) diff --git a/cmake/MatrixStructs.cmake b/cmake/MatrixStructs.cmake index 9b8baba6..cef00f61 100644 --- a/cmake/MatrixStructs.cmake +++ b/cmake/MatrixStructs.cmake @@ -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 "" ) diff --git a/cmake/Translations.cmake b/cmake/Translations.cmake new file mode 100644 index 00000000..16ca72ed --- /dev/null +++ b/cmake/Translations.cmake @@ -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) diff --git a/cmake/Tweeny.cmake b/cmake/Tweeny.cmake index 87a2ade8..537ac92c 100644 --- a/cmake/Tweeny.cmake +++ b/cmake/Tweeny.cmake @@ -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) |