Add cmake format (#4618)

* Support CMakeify operation

* Run Cmakeify

* Update cmakeify.sh

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
This commit is contained in:
Zach H 2022-05-08 15:22:43 -04:00 committed by GitHub
parent 3e90f109a2
commit a95b338c80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1132 additions and 815 deletions

106
.cmake-format.json Normal file
View file

@ -0,0 +1,106 @@
{
"format": {
"_help_line_width": [
"How wide to allow formatted cmake files"
],
"line_width": 120,
"_help_tab_size": [
"How many spaces to tab for indent"
],
"tab_size": 2,
"_help_max_subgroups_hwrap": [
"If an argument group contains more than this many sub-groups",
"(parg or kwarg groups) then force it to a vertical layout."
],
"max_subgroups_hwrap": 2,
"_help_max_pargs_hwrap": [
"If a positional argument group contains more than this many",
"arguments, then force it to a vertical layout."
],
"max_pargs_hwrap": 6,
"_help_max_rows_cmdline": [
"If a cmdline positional group consumes more than this many",
"lines without nesting, then invalidate the layout (and nest)"
],
"max_rows_cmdline": 5,
"_help_separate_ctrl_name_with_space": [
"If true, separate flow control names from their parentheses",
"with a space"
],
"separate_ctrl_name_with_space": false,
"_help_separate_fn_name_with_space": [
"If true, separate function names from parentheses with a",
"space"
],
"separate_fn_name_with_space": false,
"_help_dangle_parens": [
"If a statement is wrapped to more than one line, than dangle",
"the closing parenthesis on its own line."
],
"dangle_parens": true,
"_help_dangle_align": [
"If the trailing parenthesis must be 'dangled' on its on",
"line, then align it to this reference: `prefix`: the start",
"of the statement, `prefix-indent`: the start of the",
"statement, plus one indentation level, `child`: align to",
"the column of the arguments"
],
"dangle_align": "prefix",
"_help_min_prefix_chars": [
"If the statement spelling length (including space and",
"parenthesis) is smaller than this amount, then force reject",
"nested layouts."
],
"min_prefix_chars": 4,
"_help_max_prefix_chars": [
"If the statement spelling length (including space and",
"parenthesis) is larger than the tab width by more than this",
"amount, then force reject un-nested layouts."
],
"max_prefix_chars": 10,
"_help_max_lines_hwrap": [
"If a candidate layout is wrapped horizontally but it exceeds",
"this many lines, then reject the layout."
],
"max_lines_hwrap": 2,
"_help_line_ending": [
"What style line endings to use in the output."
],
"line_ending": "auto",
"_help_command_case": [
"Format command names consistently as 'lower' or 'upper' case"
],
"command_case": "lower",
"_help_keyword_case": [
"Format keywords consistently as 'lower' or 'upper' case"
],
"keyword_case": "upper",
"_help_always_wrap": [
"A list of command names which should always be wrapped"
],
"always_wrap": [],
"_help_enable_sort": [
"If true, the argument lists which are known to be sortable",
"will be sorted lexicographically"
],
"enable_sort": true,
"_help_autosort": [
"If true, the parsers may infer whether or not an argument",
"list is sortable (without annotation)."
],
"autosort": true,
"_help_require_valid_layout": [
"By default, if cmake-format cannot successfully fit",
"everything into the desired line-width it will apply the",
"last, most aggressive attempt that it made. If this flag is",
"True, however, cmake-format will print error, exit with non-",
"zero status code, and write-out nothing"
],
"require_valid_layout": false,
"_help_layout_passes": [
"A dictionary mapping layout nodes to a list of wrap",
"decisions. See the documentation for more information."
],
"layout_passes": {}
}
}

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# This script will run clang-format on all modified, non-3rd-party C++/Header files. # This script will run clang-format on all modified, non-3rd-party C++/Header files.
# Never, ever, should this recieve a path with a newline in it. Don't bother proofing it for that. # Never, ever, should this receive a path with a newline in it. Don't bother proofing it for that.
# go to the project root directory, this file should be located in the project root directory # go to the project root directory, this file should be located in the project root directory

View file

@ -1,18 +1,18 @@
# Find the LibExecinfo library - FreeBSD only # Find the LibExecinfo library - FreeBSD only
FIND_PATH(LIBEXECINFO_INCLUDE_DIR execinfo.h) find_path(LIBEXECINFO_INCLUDE_DIR execinfo.h)
FIND_LIBRARY(LIBEXECINFO_LIBRARY NAMES execinfo) find_library(LIBEXECINFO_LIBRARY NAMES execinfo)
IF(LIBEXECINFO_INCLUDE_DIR AND LIBEXECINFO_LIBRARY) if(LIBEXECINFO_INCLUDE_DIR AND LIBEXECINFO_LIBRARY)
SET(LIBEXECINFO_FOUND TRUE) set(LIBEXECINFO_FOUND TRUE)
ENDIF() endif()
IF(LIBEXECINFO_FOUND) if(LIBEXECINFO_FOUND)
IF(NOT LIBEXECINFO_FIND_QUIETLY) if(NOT LIBEXECINFO_FIND_QUIETLY)
MESSAGE(STATUS "Found LibExecinfo: ${EXECINFO_LIBRARY}") message(STATUS "Found LibExecinfo: ${EXECINFO_LIBRARY}")
ENDIF() endif()
ELSE() else()
IF(LIBEXECINFO_FIND_REQUIRED) if(LIBEXECINFO_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find LibExecinfo") message(FATAL_ERROR "Could not find LibExecinfo")
ENDIF() endif()
ENDIF() endif()

View file

@ -1,20 +1,23 @@
# Find a compatible Qt version # Find a compatible Qt version Inputs: WITH_SERVER, WITH_CLIENT, WITH_ORACLE, WITH_DBCONVERTER, FORCE_USE_QT5 Optional
# Inputs: WITH_SERVER, WITH_CLIENT, WITH_ORACLE, WITH_DBCONVERTER, FORCE_USE_QT5 # Input: QT6_DIR -- Hint as to where Qt6 lives on the system Optional Input: QT5_DIR -- Hint as to where Qt5 lives on
# Optional Input: QT6_DIR -- Hint as to where Qt6 lives on the system # the system Output: COCKATRICE_QT_VERSION_NAME -- Example values: Qt5, Qt6 Outputs: SERVATRICE_QT_MODULES,
# Optional Input: QT5_DIR -- Hint as to where Qt5 lives on the system # COCKATRICE_QT_MODULES, ORACLE_QT_MODULES, DBCONVERTER_QT_MODULES, TEST_QT_MODULES
# Output: COCKATRICE_QT_VERSION_NAME -- Example values: Qt5, Qt6
# Output: SERVATRICE_QT_MODULES
# Output: COCKATRICE_QT_MODULES
# Output: ORACLE_QT_MODULES
# Output: DBCONVERTER_QT_MODULES
# Output: TEST_QT_MODULES
set(REQUIRED_QT_COMPONENTS Core) set(REQUIRED_QT_COMPONENTS Core)
if(WITH_SERVER) if(WITH_SERVER)
set(_SERVATRICE_NEEDED Network Sql WebSockets) set(_SERVATRICE_NEEDED Network Sql WebSockets)
endif() endif()
if(WITH_CLIENT) if(WITH_CLIENT)
set(_COCKATRICE_NEEDED Concurrent Gui Multimedia Network PrintSupport Svg Widgets WebSockets) set(_COCKATRICE_NEEDED
Concurrent
Gui
Multimedia
Network
PrintSupport
Svg
Widgets
WebSockets
)
endif() endif()
if(WITH_ORACLE) if(WITH_ORACLE)
set(_ORACLE_NEEDED Concurrent Network Svg Widgets) set(_ORACLE_NEEDED Concurrent Network Svg Widgets)
@ -26,22 +29,19 @@ if(TEST)
set(_TEST_NEEDED Widgets) set(_TEST_NEEDED Widgets)
endif() endif()
set(REQUIRED_QT_COMPONENTS set(REQUIRED_QT_COMPONENTS ${REQUIRED_QT_COMPONENTS} ${_SERVATRICE_NEEDED} ${_COCKATRICE_NEEDED} ${_ORACLE_NEEDED}
${REQUIRED_QT_COMPONENTS} ${_DBCONVERTER_NEEDED} ${_TEST_NEEDED}
${_SERVATRICE_NEEDED} )
${_COCKATRICE_NEEDED}
${_ORACLE_NEEDED}
${_DBCONVERTER_NEEDED}
${_TEST_NEEDED})
list(REMOVE_DUPLICATES REQUIRED_QT_COMPONENTS) list(REMOVE_DUPLICATES REQUIRED_QT_COMPONENTS)
if(NOT FORCE_USE_QT5) if(NOT FORCE_USE_QT5)
# Core5Compat is Qt6 Only, Linguist is now a component in Qt6 instead of an external package # Core5Compat is Qt6 Only, Linguist is now a component in Qt6 instead of an external package
find_package(Qt6 6.2.3 find_package(
Qt6 6.2.3
COMPONENTS Core5Compat ${REQUIRED_QT_COMPONENTS} COMPONENTS Core5Compat ${REQUIRED_QT_COMPONENTS}
OPTIONAL_COMPONENTS Linguist OPTIONAL_COMPONENTS Linguist
QUIET QUIET HINTS ${Qt6_DIR}
HINTS ${Qt6_DIR}) )
endif() endif()
if(Qt6_FOUND) if(Qt6_FOUND)
set(COCKATRICE_QT_VERSION_NAME Qt6) set(COCKATRICE_QT_VERSION_NAME Qt6)
@ -58,10 +58,11 @@ if(Qt6_FOUND)
endif() endif()
endif() endif()
else() else()
find_package(Qt5 5.8.0 find_package(
Qt5 5.8.0
COMPONENTS ${REQUIRED_QT_COMPONENTS} COMPONENTS ${REQUIRED_QT_COMPONENTS}
QUIET QUIET HINTS ${Qt5_DIR}
HINTS ${Qt5_DIR}) )
if(Qt5_FOUND) if(Qt5_FOUND)
set(COCKATRICE_QT_VERSION_NAME Qt5) set(COCKATRICE_QT_VERSION_NAME Qt5)
else() else()
@ -70,7 +71,7 @@ else()
# Qt5 Linguist is in a separate package # Qt5 Linguist is in a separate package
find_package(Qt5LinguistTools QUIET) find_package(Qt5LinguistTools QUIET)
if (Qt5LinguistTools_FOUND) if(Qt5LinguistTools_FOUND)
if(NOT Qt5_LRELEASE_EXECUTABLE) if(NOT Qt5_LRELEASE_EXECUTABLE)
message(WARNING "Qt5 lrelease not found.") message(WARNING "Qt5 lrelease not found.")
endif() endif()
@ -112,7 +113,7 @@ string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" TEST_QT_MODU
if(Qt6_FOUND) if(Qt6_FOUND)
list(APPEND SERVATRICE_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Core5Compat) list(APPEND SERVATRICE_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Core5Compat)
list(APPEND COCKATRICE_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Core5Compat) list(APPEND COCKATRICE_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Core5Compat)
LIST(APPEND ORACLE_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Core5Compat) list(APPEND ORACLE_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Core5Compat)
endif() endif()
message(STATUS "Found Qt ${${COCKATRICE_QT_VERSION_NAME}_VERSION} at: ${${COCKATRICE_QT_VERSION_NAME}_DIR}") message(STATUS "Found Qt ${${COCKATRICE_QT_VERSION_NAME}_VERSION} at: ${${COCKATRICE_QT_VERSION_NAME}_DIR}")

View file

@ -1,6 +1,6 @@
# Find the MS Visual Studio VC redistributable package # Find the MS Visual Studio VC redistributable package
if (WIN32) if(WIN32)
set(VCREDISTRUNTIME_FOUND "NO") set(VCREDISTRUNTIME_FOUND "NO")
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
@ -16,13 +16,13 @@ if (WIN32)
# Check if the list contains minimum one element, to get the path from # Check if the list contains minimum one element, to get the path from
list(LENGTH CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS libsCount) list(LENGTH CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS libsCount)
if (libsCount GREATER 0) if(libsCount GREATER 0)
list(GET CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS 0 _path) list(GET CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS 0 _path)
get_filename_component(_path ${_path} DIRECTORY) get_filename_component(_path ${_path} DIRECTORY)
get_filename_component(_path ${_path}/../../ ABSOLUTE) get_filename_component(_path ${_path}/../../ ABSOLUTE)
if (EXISTS "${_path}/${REDIST_FILE}") # VS 2017 if(EXISTS "${_path}/${REDIST_FILE}") # VS 2017
set(VCREDISTRUNTIME_FOUND "YES") set(VCREDISTRUNTIME_FOUND "YES")
set(VCREDISTRUNTIME_FILE ${_path}/${REDIST_FILE}) set(VCREDISTRUNTIME_FILE ${_path}/${REDIST_FILE})
endif() endif()
@ -31,6 +31,8 @@ if (WIN32)
if(VCREDISTRUNTIME_FOUND) if(VCREDISTRUNTIME_FOUND)
message(STATUS "Found VCredist ${VCREDISTRUNTIME_FILE}") message(STATUS "Found VCredist ${VCREDISTRUNTIME_FILE}")
else() else()
message(WARNING "Could not find VCredist package. It's not required for compiling, but needs to be available at runtime.") message(
WARNING "Could not find VCredist package. It's not required for compiling, but needs to be available at runtime."
)
endif() endif()
endif() endif()

View file

@ -1,5 +1,4 @@
# Find the OpenSSL runtime libraries (.dll) for Windows that # Find the OpenSSL runtime libraries (.dll) for Windows that will be needed by Qt in order to access https urls.
# will be needed by Qt in order to access https urls.
if(NOT DEFINED WIN32 OR NOT ${WIN32}) if(NOT DEFINED WIN32 OR NOT ${WIN32})
message(STATUS "Non-Windows device trying to execute FindWin32SslRuntime, skipping") message(STATUS "Non-Windows device trying to execute FindWin32SslRuntime, skipping")
return() return()
@ -8,12 +7,8 @@ endif()
if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64") if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64")
message(STATUS "Looking for OpenSSL for ${CMAKE_GENERATOR_PLATFORM}") message(STATUS "Looking for OpenSSL for ${CMAKE_GENERATOR_PLATFORM}")
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles) file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
set(_OPENSSL_ROOT_PATHS set(_OPENSSL_ROOT_PATHS "$ENV{VCPKG_PACKAGES_DIR}/x64-windows/bin" "C:/OpenSSL-Win64/bin" "C:/OpenSSL-Win64"
"$ENV{VCPKG_PACKAGES_DIR}/x64-windows/bin" "C:/Tools/vcpkg/installed/x64-windows/bin" "${_programfiles}/OpenSSL-Win64"
"C:/OpenSSL-Win64/bin"
"C:/OpenSSL-Win64"
"C:/Tools/vcpkg/installed/x64-windows/bin"
"${_programfiles}/OpenSSL-Win64"
) )
unset(_programfiles) unset(_programfiles)
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32") elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")
@ -33,23 +28,43 @@ endif()
message(STATUS "Looking for OpenSSL @ $ENV{CMAKE_GENERATOR_PLATFORM} in ${_OPENSSL_ROOT_PATHS}") message(STATUS "Looking for OpenSSL @ $ENV{CMAKE_GENERATOR_PLATFORM} in ${_OPENSSL_ROOT_PATHS}")
if("$ENV{CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64") if("$ENV{CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64")
FIND_FILE(WIN32SSLRUNTIME_LIBEAY NAMES libcrypto-1_1-x64.dll libcrypto.dll PATHS ${_OPENSSL_ROOT_PATHS} NO_DEFAULT_PATH) find_file(
FIND_FILE(WIN32SSLRUNTIME_SSLEAY NAMES libssl-1_1-x64.dll libssl.dll PATHS ${_OPENSSL_ROOT_PATHS} NO_DEFAULT_PATH) WIN32SSLRUNTIME_LIBEAY
NAMES libcrypto-1_1-x64.dll libcrypto.dll
PATHS ${_OPENSSL_ROOT_PATHS}
NO_DEFAULT_PATH
)
find_file(
WIN32SSLRUNTIME_SSLEAY
NAMES libssl-1_1-x64.dll libssl.dll
PATHS ${_OPENSSL_ROOT_PATHS}
NO_DEFAULT_PATH
)
elseif("$ENV{CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32") elseif("$ENV{CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")
FIND_FILE(WIN32SSLRUNTIME_LIBEAY NAMES libcrypto-1_1.dll libcrypto.dll PATHS ${_OPENSSL_ROOT_PATHS} NO_DEFAULT_PATH) find_file(
FIND_FILE(WIN32SSLRUNTIME_SSLEAY NAMES libssl-1_1.dll libssl.dll PATHS ${_OPENSSL_ROOT_PATHS} NO_DEFAULT_PATH) WIN32SSLRUNTIME_LIBEAY
NAMES libcrypto-1_1.dll libcrypto.dll
PATHS ${_OPENSSL_ROOT_PATHS}
NO_DEFAULT_PATH
)
find_file(
WIN32SSLRUNTIME_SSLEAY
NAMES libssl-1_1.dll libssl.dll
PATHS ${_OPENSSL_ROOT_PATHS}
NO_DEFAULT_PATH
)
endif() endif()
IF(WIN32SSLRUNTIME_LIBEAY AND WIN32SSLRUNTIME_SSLEAY) if(WIN32SSLRUNTIME_LIBEAY AND WIN32SSLRUNTIME_SSLEAY)
SET(WIN32SSLRUNTIME_LIBRARIES "${WIN32SSLRUNTIME_LIBEAY}" "${WIN32SSLRUNTIME_SSLEAY}") set(WIN32SSLRUNTIME_LIBRARIES "${WIN32SSLRUNTIME_LIBEAY}" "${WIN32SSLRUNTIME_SSLEAY}")
SET(WIN32SSLRUNTIME_FOUND "YES") set(WIN32SSLRUNTIME_FOUND "YES")
message(STATUS "Found OpenSSL ${WIN32SSLRUNTIME_LIBRARIES}") message(STATUS "Found OpenSSL ${WIN32SSLRUNTIME_LIBRARIES}")
ELSE() else()
SET(WIN32SSLRUNTIME_FOUND "NO") set(WIN32SSLRUNTIME_FOUND "NO")
message(WARNING "Could not find OpenSSL runtime libraries. They are not required for compiling, but needs to be available at runtime.") message(
ENDIF() WARNING
"Could not find OpenSSL runtime libraries. They are not required for compiling, but needs to be available at runtime."
MARK_AS_ADVANCED(
WIN32SSLRUNTIME_LIBEAY
WIN32SSLRUNTIME_SSLEAY
) )
endif()
mark_as_advanced(WIN32SSLRUNTIME_LIBEAY WIN32SSLRUNTIME_SSLEAY)

View file

@ -1,16 +1,20 @@
set(VERSION_STRING_CPP "${PROJECT_BINARY_DIR}/version_string.cpp") set(VERSION_STRING_CPP "${PROJECT_BINARY_DIR}/version_string.cpp")
set(VERSION_STRING_H "${PROJECT_BINARY_DIR}/version_string.h") set(VERSION_STRING_H "${PROJECT_BINARY_DIR}/version_string.h")
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) include_directories(${PROJECT_BINARY_DIR})
set( hstring "extern const char *VERSION_STRING\; set(hstring
"extern const char *VERSION_STRING\;
extern const char *VERSION_COMMIT\; extern const char *VERSION_COMMIT\;
extern const char *VERSION_DATE\;\n" ) extern const char *VERSION_DATE\;\n"
set( cppstring "const char *VERSION_STRING = \"${PROJECT_VERSION_FRIENDLY}\"\; )
set(cppstring
"const char *VERSION_STRING = \"${PROJECT_VERSION_FRIENDLY}\"\;
const char *VERSION_COMMIT = \"${GIT_COMMIT_ID}\"\; const char *VERSION_COMMIT = \"${GIT_COMMIT_ID}\"\;
const char *VERSION_DATE = \"${GIT_COMMIT_DATE_FRIENDLY}\"\;\n") const char *VERSION_DATE = \"${GIT_COMMIT_DATE_FRIENDLY}\"\;\n"
)
file(WRITE ${PROJECT_BINARY_DIR}/version_string.cpp.txt ${cppstring} ) file(WRITE ${PROJECT_BINARY_DIR}/version_string.cpp.txt ${cppstring})
file(WRITE ${PROJECT_BINARY_DIR}/version_string.h.txt ${hstring} ) file(WRITE ${PROJECT_BINARY_DIR}/version_string.h.txt ${hstring})
execute_process( execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_BINARY_DIR}/version_string.h.txt ${VERSION_STRING_H} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_BINARY_DIR}/version_string.h.txt ${VERSION_STRING_H}
@ -18,4 +22,3 @@ execute_process(
execute_process( execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_BINARY_DIR}/version_string.cpp.txt ${VERSION_STRING_CPP} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_BINARY_DIR}/version_string.cpp.txt ${VERSION_STRING_CPP}
) )

View file

@ -14,8 +14,14 @@ function(get_commit_id)
endif() endif()
string(REPLACE "\n" "" GIT_COM_ID "${GIT_COM_ID}") string(REPLACE "\n" "" GIT_COM_ID "${GIT_COM_ID}")
set(GIT_COMMIT_ID "${GIT_COM_ID}" PARENT_SCOPE) set(GIT_COMMIT_ID
set(PROJECT_VERSION_LABEL "custom(${GIT_COM_ID})" PARENT_SCOPE) "${GIT_COM_ID}"
PARENT_SCOPE
)
set(PROJECT_VERSION_LABEL
"custom(${GIT_COM_ID})"
PARENT_SCOPE
)
endfunction() endfunction()
function(get_commit_date) function(get_commit_date)
@ -32,10 +38,16 @@ function(get_commit_date)
endif() endif()
string(REPLACE "\n" "" GIT_COM_DATE "${GIT_COM_DATE}") string(REPLACE "\n" "" GIT_COM_DATE "${GIT_COM_DATE}")
set(GIT_COMMIT_DATE_FRIENDLY "${GIT_COM_DATE}" PARENT_SCOPE) set(GIT_COMMIT_DATE_FRIENDLY
"${GIT_COM_DATE}"
PARENT_SCOPE
)
string(REPLACE "-" "" GIT_COM_DATE "${GIT_COM_DATE}") string(REPLACE "-" "" GIT_COM_DATE "${GIT_COM_DATE}")
set(GIT_COMMIT_DATE "${GIT_COM_DATE}" PARENT_SCOPE) set(GIT_COMMIT_DATE
"${GIT_COM_DATE}"
PARENT_SCOPE
)
endfunction() endfunction()
function(get_tag_name commit) function(get_tag_name commit)
@ -59,9 +71,7 @@ function(get_tag_name commit)
string(REPLACE "\n" "" GIT_TAG "${GIT_TAG}") string(REPLACE "\n" "" GIT_TAG "${GIT_TAG}")
message(STATUS "Commit is a release or prerelease, git tag: ${GIT_TAG}") message(STATUS "Commit is a release or prerelease, git tag: ${GIT_TAG}")
# Extract information from tag: # Extract information from tag: YYYY-MM-DD-Release-MAJ.MIN.PATCH YYYY-MM-DD-Development-MAJ.MIN.PATCH-beta.X
# YYYY-MM-DD-Release-MAJ.MIN.PATCH
# YYYY-MM-DD-Development-MAJ.MIN.PATCH-beta.X
string(REPLACE "-" ";" GIT_TAG_EXPLODED "${GIT_TAG}") string(REPLACE "-" ";" GIT_TAG_EXPLODED "${GIT_TAG}")
string(REPLACE "." ";" GIT_TAG_EXPLODED "${GIT_TAG_EXPLODED}") string(REPLACE "." ";" GIT_TAG_EXPLODED "${GIT_TAG_EXPLODED}")
@ -95,7 +105,7 @@ function(get_tag_name commit)
# Type # Type
list(GET GIT_TAG_EXPLODED 3 GIT_TAG_TYPE) list(GET GIT_TAG_EXPLODED 3 GIT_TAG_TYPE)
if(NOT(${GIT_TAG_TYPE} STREQUAL "Release" OR ${GIT_TAG_TYPE} STREQUAL "Development")) if(NOT (${GIT_TAG_TYPE} STREQUAL "Release" OR ${GIT_TAG_TYPE} STREQUAL "Development"))
message(WARNING "Invalid tag type ${GIT_TAG_TYPE}") message(WARNING "Invalid tag type ${GIT_TAG_TYPE}")
return() return()
endif() endif()
@ -121,10 +131,8 @@ function(get_tag_name commit)
return() return()
endif() endif()
# Label # Label 7 = Stable release 8 = Dev release, first beta so only "beta" attached 9 = Dev release, subsequent beta so
# 7 = Stable release # "beta.N" attached (N>=2)
# 8 = Dev release, first beta so only "beta" attached
# 9 = Dev release, subsequent beta so "beta.N" attached (N>=2)
if(${GIT_TAG_LISTCOUNT} EQUAL 8) if(${GIT_TAG_LISTCOUNT} EQUAL 8)
list(GET GIT_TAG_EXPLODED 7 GIT_TAG_LABEL) list(GET GIT_TAG_EXPLODED 7 GIT_TAG_LABEL)
elseif(${GIT_TAG_LISTCOUNT} EQUAL 9) elseif(${GIT_TAG_LISTCOUNT} EQUAL 9)
@ -133,21 +141,42 @@ function(get_tag_name commit)
set(GIT_TAG_LABEL ${GIT_TAG_LABEL} ${GIT_TAG_LABEL_NUM}) set(GIT_TAG_LABEL ${GIT_TAG_LABEL} ${GIT_TAG_LABEL_NUM})
string(REPLACE ";" "." GIT_TAG_LABEL "${GIT_TAG_LABEL}") string(REPLACE ";" "." GIT_TAG_LABEL "${GIT_TAG_LABEL}")
else() else()
SET(GIT_TAG_LABEL "") set(GIT_TAG_LABEL "")
endif() endif()
# Override hardcoded version with the informations from the tag # Override hardcoded version with the informations from the tag
set(PROJECT_VERSION_MAJOR ${GIT_TAG_MAJOR} PARENT_SCOPE) set(PROJECT_VERSION_MAJOR
set(PROJECT_VERSION_MINOR ${GIT_TAG_MINOR} PARENT_SCOPE) ${GIT_TAG_MAJOR}
set(PROJECT_VERSION_PATCH ${GIT_TAG_PATCH} PARENT_SCOPE) PARENT_SCOPE
set(PROJECT_VERSION_LABEL ${GIT_TAG_LABEL} PARENT_SCOPE) )
set(PROJECT_VERSION_MINOR
${GIT_TAG_MINOR}
PARENT_SCOPE
)
set(PROJECT_VERSION_PATCH
${GIT_TAG_PATCH}
PARENT_SCOPE
)
set(PROJECT_VERSION_LABEL
${GIT_TAG_LABEL}
PARENT_SCOPE
)
if(${GIT_TAG_TYPE} STREQUAL "Development") if(${GIT_TAG_TYPE} STREQUAL "Development")
set(PROJECT_VERSION_LABEL ${GIT_TAG_LABEL} PARENT_SCOPE) set(PROJECT_VERSION_LABEL
${GIT_TAG_LABEL}
PARENT_SCOPE
)
elseif(${GIT_TAG_TYPE} STREQUAL "Release") elseif(${GIT_TAG_TYPE} STREQUAL "Release")
set(PROJECT_VERSION_LABEL "" PARENT_SCOPE) set(PROJECT_VERSION_LABEL
""
PARENT_SCOPE
)
# set release name from env var # set release name from env var
set(PROJECT_VERSION_RELEASENAME "${GIT_TAG_RELEASENAME}" PARENT_SCOPE) set(PROJECT_VERSION_RELEASENAME
"${GIT_TAG_RELEASENAME}"
PARENT_SCOPE
)
endif() endif()
endfunction() endfunction()
@ -167,7 +196,7 @@ if(GIT_FOUND)
get_commit_date() get_commit_date()
get_tag_name(${GIT_COMMIT_ID}) get_tag_name(${GIT_COMMIT_ID})
else() else()
message( WARNING "Git not found. Build will not contain git revision info." ) message(WARNING "Git not found. Build will not contain git revision info.")
endif() endif()
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")

14
cmakeify.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
# go to the project root directory, this file should be located in the project root directory
cd "${BASH_SOURCE%/*}/" || exit 2 # could not find path, this could happen with special links etc.
# CMake-Format
cmake_format_cmd="cmake-format"
if ! hash $cmake_format_cmd 2>/dev/null; then
echo "could not find $cmake_format_cmd, skipping" >&2
return
fi
$cmake_format_cmd -i cmake/*.cmake */CMakeLists.txt CMakeLists.txt

View file

@ -2,9 +2,9 @@
# #
# provides the cockatrice binary # provides the cockatrice binary
PROJECT(Cockatrice VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") project(Cockatrice VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
SET(cockatrice_SOURCES set(cockatrice_SOURCES
src/abstractcarddragitem.cpp src/abstractcarddragitem.cpp
src/abstractcarditem.cpp src/abstractcarditem.cpp
src/abstractclient.cpp src/abstractclient.cpp
@ -127,21 +127,23 @@ SET(cockatrice_SOURCES
src/zoneviewwidget.cpp src/zoneviewwidget.cpp
src/zoneviewzone.cpp src/zoneviewzone.cpp
${VERSION_STRING_CPP} ${VERSION_STRING_CPP}
) )
add_subdirectory(sounds) add_subdirectory(sounds)
add_subdirectory(themes) add_subdirectory(themes)
set(cockatrice_RESOURCES cockatrice.qrc) set(cockatrice_RESOURCES cockatrice.qrc)
IF(UPDATE_TRANSLATIONS) if(UPDATE_TRANSLATIONS)
FILE(GLOB_RECURSE translate_cockatrice_SRCS ${CMAKE_SOURCE_DIR}/cockatrice/src/*.cpp ${CMAKE_SOURCE_DIR}/cockatrice/src/*.h) file(GLOB_RECURSE translate_cockatrice_SRCS ${CMAKE_SOURCE_DIR}/cockatrice/src/*.cpp
FILE(GLOB_RECURSE translate_common_SRCS ${CMAKE_SOURCE_DIR}/common/*.cpp ${CMAKE_SOURCE_DIR}/common/*.h) ${CMAKE_SOURCE_DIR}/cockatrice/src/*.h
SET(translate_SRCS ${translate_cockatrice_SRCS} ${translate_common_SRCS}) )
SET(cockatrice_TS "${CMAKE_CURRENT_SOURCE_DIR}/cockatrice_en@source.ts") file(GLOB_RECURSE translate_common_SRCS ${CMAKE_SOURCE_DIR}/common/*.cpp ${CMAKE_SOURCE_DIR}/common/*.h)
ELSE() set(translate_SRCS ${translate_cockatrice_SRCS} ${translate_common_SRCS})
FILE(GLOB cockatrice_TS "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts") set(cockatrice_TS "${CMAKE_CURRENT_SOURCE_DIR}/cockatrice_en@source.ts")
ENDIF(UPDATE_TRANSLATIONS) else()
file(GLOB cockatrice_TS "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts")
endif(UPDATE_TRANSLATIONS)
if(WIN32) if(WIN32)
set(cockatrice_SOURCES ${cockatrice_SOURCES} cockatrice.rc) set(cockatrice_SOURCES ${cockatrice_SOURCES} cockatrice.rc)
@ -149,32 +151,48 @@ endif(WIN32)
if(APPLE) if(APPLE)
set(MACOSX_BUNDLE_ICON_FILE appicon.icns) set(MACOSX_BUNDLE_ICON_FILE appicon.icns)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources
)
set(cockatrice_SOURCES ${cockatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns) set(cockatrice_SOURCES ${cockatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
ENDIF(APPLE) endif(APPLE)
IF(Qt6_FOUND) if(Qt6_FOUND)
Qt6_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) qt6_add_resources(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
ELSEIF(Qt5_FOUND) elseif(Qt5_FOUND)
Qt5_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) qt5_add_resources(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
ENDIF() endif()
# Declare path variables # Declare path variables
set(ICONDIR share/icons CACHE STRING "icon dir") set(ICONDIR
set(DESKTOPDIR share/applications CACHE STRING "desktop file destination") share/icons
CACHE STRING "icon dir"
)
set(DESKTOPDIR
share/applications
CACHE STRING "desktop file destination"
)
# Include directories # Include directories
INCLUDE_DIRECTORIES(../common) include_directories(../common)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) include_directories(${PROTOBUF_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/common) include_directories(${CMAKE_BINARY_DIR}/common)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(COCKATRICE_MAC_QM_INSTALL_DIR "cockatrice.app/Contents/Resources/translations") set(COCKATRICE_MAC_QM_INSTALL_DIR "cockatrice.app/Contents/Resources/translations")
set(COCKATRICE_UNIX_QM_INSTALL_DIR "share/cockatrice/translations") set(COCKATRICE_UNIX_QM_INSTALL_DIR "share/cockatrice/translations")
set(COCKATRICE_WIN32_QM_INSTALL_DIR "translations") set(COCKATRICE_WIN32_QM_INSTALL_DIR "translations")
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_add_executable(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS} MANUAL_FINALIZATION) qt6_add_executable(
cockatrice
WIN32
MACOSX_BUNDLE
${cockatrice_SOURCES}
${cockatrice_RESOURCES_RCC}
${cockatrice_MOC_SRCS}
MANUAL_FINALIZATION
)
elseif(Qt5_FOUND) elseif(Qt5_FOUND)
# Qt5 Translations need to be linked at executable creation time # Qt5 Translations need to be linked at executable creation time
if(Qt5LinguistTools_FOUND) if(Qt5LinguistTools_FOUND)
@ -184,7 +202,10 @@ elseif(Qt5_FOUND)
qt5_add_translation(cockatrice_QM ${cockatrice_TS}) qt5_add_translation(cockatrice_QM ${cockatrice_TS})
endif() endif()
endif() endif()
add_executable(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS}) add_executable(
cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_MOC_SRCS} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC}
${cockatrice_SOURCES}
)
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
install(FILES ${cockatrice_QM} DESTINATION ${COCKATRICE_MAC_QM_INSTALL_DIR}) install(FILES ${cockatrice_QM} DESTINATION ${COCKATRICE_MAC_QM_INSTALL_DIR})
@ -213,16 +234,16 @@ if(UNIX)
set_target_properties(cockatrice PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/Info.plist) set_target_properties(cockatrice PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/Info.plist)
INSTALL(TARGETS cockatrice BUNDLE DESTINATION ./) install(TARGETS cockatrice BUNDLE DESTINATION ./)
else() else()
# Assume linux # Assume linux
INSTALL(TARGETS cockatrice RUNTIME DESTINATION bin/) install(TARGETS cockatrice RUNTIME DESTINATION bin/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/cockatrice.png DESTINATION ${ICONDIR}/hicolor/48x48/apps) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/cockatrice.png DESTINATION ${ICONDIR}/hicolor/48x48/apps)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/cockatrice.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/cockatrice.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cockatrice.desktop DESTINATION ${DESKTOPDIR}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cockatrice.desktop DESTINATION ${DESKTOPDIR})
endif() endif()
elseif(WIN32) elseif(WIN32)
INSTALL(TARGETS cockatrice RUNTIME DESTINATION ./) install(TARGETS cockatrice RUNTIME DESTINATION ./)
endif() endif()
if(APPLE) if(APPLE)
@ -231,7 +252,10 @@ if(APPLE)
set(qtconf_dest_dir cockatrice.app/Contents/Resources) set(qtconf_dest_dir cockatrice.app/Contents/Resources)
# Qt plugins: audio (Qt5), iconengines, imageformats, platforms, printsupport (Qt5), styles, tls (Qt6) # Qt plugins: audio (Qt5), iconengines, imageformats, platforms, printsupport (Qt5), styles, tls (Qt6)
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING FILES_MATCHING
PATTERN "*.dSYM" EXCLUDE PATTERN "*.dSYM" EXCLUDE
PATTERN "*_debug.dylib" EXCLUDE PATTERN "*_debug.dylib" EXCLUDE
@ -244,20 +268,26 @@ if(APPLE)
PATTERN "tls/*.dylib" PATTERN "tls/*.dylib"
) )
install(CODE " install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins Plugins = Plugins
Translations = Resources/translations Translations = Resources/translations
Data = Resources\") Data = Resources\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
install(CODE " install(
CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
endif() endif()
if(WIN32) if(WIN32)
@ -265,10 +295,19 @@ if(WIN32)
set(plugin_dest_dir Plugins) set(plugin_dest_dir Plugins)
set(qtconf_dest_dir .) set(qtconf_dest_dir .)
install(DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" DESTINATION ./ FILES_MATCHING PATTERN "*.dll") install(
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"
DESTINATION ./
FILES_MATCHING
PATTERN "*.dll"
)
# Qt plugins: audio (Qt5), iconengines, imageformats, platforms, printsupport (Qt5), styles, tls (Qt6) # Qt plugins: audio (Qt5), iconengines, imageformats, platforms, printsupport (Qt5), styles, tls (Qt6)
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime FILES_MATCHING install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING
PATTERN "audio/qtaudio_wasapi.dll" PATTERN "audio/qtaudio_wasapi.dll"
PATTERN "audio/qtaudio_windows.dll" PATTERN "audio/qtaudio_windows.dll"
PATTERN "iconengines/qsvgicon.dll" PATTERN "iconengines/qsvgicon.dll"
@ -292,22 +331,29 @@ if(WIN32)
PATTERN "styles/qwindowsvistastyle.dll" PATTERN "styles/qwindowsvistastyle.dll"
PATTERN "tls/qcertonlybackend.dll" PATTERN "tls/qcertonlybackend.dll"
PATTERN "tls/qopensslbackend.dll" PATTERN "tls/qopensslbackend.dll"
PATTERN "tls/qschannelbackend.dll") PATTERN "tls/qschannelbackend.dll"
)
install(CODE " install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins Plugins = Plugins
Translations = Resources/translations Translations = Resources/translations
Data = Resources\") Data = Resources\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
install(CODE " install(
CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\")
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Cockatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Cockatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
if(WIN32SSLRUNTIME_FOUND) if(WIN32SSLRUNTIME_FOUND)
install(FILES ${WIN32SSLRUNTIME_LIBRARIES} DESTINATION ./) install(FILES ${WIN32SSLRUNTIME_LIBRARIES} DESTINATION ./)
@ -315,9 +361,17 @@ Data = Resources\")
endif() endif()
if(Qt6LinguistTools_FOUND) if(Qt6LinguistTools_FOUND)
#Qt6 Translations happen after the executable is built up # Qt6 Translations happen after the executable is built up
if(UPDATE_TRANSLATIONS) if(UPDATE_TRANSLATIONS)
qt6_add_translations(cockatrice TS_FILES ${cockatrice_TS} SOURCES ${translate_SRCS} QM_FILES_OUTPUT_VARIABLE cockatrice_QM) qt6_add_translations(
cockatrice
TS_FILES
${cockatrice_TS}
SOURCES
${translate_SRCS}
QM_FILES_OUTPUT_VARIABLE
cockatrice_QM
)
else() else()
qt6_add_translations(cockatrice TS_FILES ${cockatrice_TS} QM_FILES_OUTPUT_VARIABLE cockatrice_QM) qt6_add_translations(cockatrice TS_FILES ${cockatrice_TS} QM_FILES_OUTPUT_VARIABLE cockatrice_QM)
endif() endif()

View file

@ -2,18 +2,15 @@
# #
# add sounds subfolders # add sounds subfolders
SET(defsounds set(defsounds Default Legacy)
Default
Legacy
)
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
INSTALL(DIRECTORY ${defsounds} DESTINATION Cockatrice.app/Contents/Resources/sounds/) install(DIRECTORY ${defsounds} DESTINATION Cockatrice.app/Contents/Resources/sounds/)
else() else()
# Assume linux # Assume linux
INSTALL(DIRECTORY ${defsounds} DESTINATION share/cockatrice/sounds/) install(DIRECTORY ${defsounds} DESTINATION share/cockatrice/sounds/)
endif() endif()
elseif(WIN32) elseif(WIN32)
INSTALL(DIRECTORY ${defsounds} DESTINATION sounds/) install(DIRECTORY ${defsounds} DESTINATION sounds/)
endif() endif()

View file

@ -2,20 +2,15 @@
# #
# add themes subfolders # add themes subfolders
SET(defthemes set(defthemes Fabric Leather Plasma VelvetMarble)
Fabric
Leather
Plasma
VelvetMarble
)
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
INSTALL(DIRECTORY ${defthemes} DESTINATION Cockatrice.app/Contents/Resources/themes/) install(DIRECTORY ${defthemes} DESTINATION Cockatrice.app/Contents/Resources/themes/)
else() else()
# Assume linux # Assume linux
INSTALL(DIRECTORY ${defthemes} DESTINATION share/cockatrice/themes/) install(DIRECTORY ${defthemes} DESTINATION share/cockatrice/themes/)
endif() endif()
elseif(WIN32) elseif(WIN32)
INSTALL(DIRECTORY ${defthemes} DESTINATION themes/) install(DIRECTORY ${defthemes} DESTINATION themes/)
endif() endif()

View file

@ -4,7 +4,7 @@
add_subdirectory(pb) add_subdirectory(pb)
SET(common_SOURCES set(common_SOURCES
debug_pb_message.cpp debug_pb_message.cpp
decklist.cpp decklist.cpp
expression.cpp expression.cpp
@ -33,11 +33,11 @@ SET(common_SOURCES
set(ORACLE_LIBS) set(ORACLE_LIBS)
INCLUDE_DIRECTORIES(pb) include_directories(pb)
INCLUDE_DIRECTORIES(sfmt) include_directories(sfmt)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${${COCKATRICE_QT_VERSION_NAME}Core_INCLUDE_DIRS}) include_directories(${${COCKATRICE_QT_VERSION_NAME}Core_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library(cockatrice_common ${common_SOURCES} ${common_MOC_SRCS}) add_library(cockatrice_common ${common_SOURCES} ${common_MOC_SRCS})
target_link_libraries(cockatrice_common PUBLIC cockatrice_protocol) target_link_libraries(cockatrice_common PUBLIC cockatrice_protocol)

View file

@ -2,7 +2,7 @@
# #
# provides the protobuf interfaces # provides the protobuf interfaces
SET(PROTO_FILES set(PROTO_FILES
admin_commands.proto admin_commands.proto
card_attributes.proto card_attributes.proto
color.proto color.proto
@ -162,21 +162,21 @@ SET(PROTO_FILES
include_directories(${PROTOBUF_INCLUDE_DIRS}) include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${PROTO_FILES}) protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
add_library(cockatrice_protocol ${PROTO_SRCS} ${PROTO_HDRS}) add_library(cockatrice_protocol ${PROTO_SRCS} ${PROTO_HDRS})
set(cockatrice_protocol_LIBS ${PROTOBUF_LIBRARIES}) set(cockatrice_protocol_LIBS ${PROTOBUF_LIBRARIES})
if (UNIX) if(UNIX)
set(cockatrice_protocol_LIBS ${cockatrice_protocol_LIBS} -lpthread) set(cockatrice_protocol_LIBS ${cockatrice_protocol_LIBS} -lpthread)
endif (UNIX) endif(UNIX)
target_link_libraries(cockatrice_protocol ${cockatrice_protocol_LIBS}) target_link_libraries(cockatrice_protocol ${cockatrice_protocol_LIBS})
# ubuntu uses an outdated package for protobuf, 3.1.0 is required # ubuntu uses an outdated package for protobuf, 3.1.0 is required
if(${Protobuf_VERSION} VERSION_LESS "3.1.0") if(${Protobuf_VERSION} VERSION_LESS "3.1.0")
# remove unused parameter and misleading indentation warnings when compiling to avoid errors # remove unused parameter and misleading indentation warnings when compiling to avoid errors
set(CMAKE_CXX_FLAGS_DEBUG set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-parameter -Wno-misleading-indentation")
"${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-parameter -Wno-misleading-indentation")
message(WARNING "Older protobuf version found (${Protobuf_VERSION} < 3.1.0), " message(WARNING "Older protobuf version found (${Protobuf_VERSION} < 3.1.0), "
"disabled the warnings 'unused-parameter' and 'misleading-indentation' for protobuf generated code " "disabled the warnings 'unused-parameter' and 'misleading-indentation' for protobuf generated code "
"to avoid compilation errors.") "to avoid compilation errors."
)
endif() endif()

View file

@ -1,8 +1,8 @@
# CMakeLists for dbconverter directory # CMakeLists for dbconverter directory
PROJECT(Dbconverter VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") project(Dbconverter VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
SET(dbconverter_SOURCES set(dbconverter_SOURCES
src/main.cpp src/main.cpp
src/mocks.cpp src/mocks.cpp
../cockatrice/src/carddatabase.cpp ../cockatrice/src/carddatabase.cpp
@ -13,25 +13,18 @@ SET(dbconverter_SOURCES
${VERSION_STRING_CPP} ${VERSION_STRING_CPP}
) )
set(QT_DONT_USE_QTGUI TRUE)
SET(QT_DONT_USE_QTGUI TRUE) if(Qt6_FOUND)
qt6_wrap_cpp(dbconverter_SOURCES ../cockatrice/src/settingscache.h ../cockatrice/src/settings/carddatabasesettings.h)
IF(Qt6_FOUND) elseif(Qt5_FOUND)
Qt6_WRAP_CPP(dbconverter_SOURCES qt5_wrap_cpp(dbconverter_SOURCES ../cockatrice/src/settingscache.h ../cockatrice/src/settings/carddatabasesettings.h)
../cockatrice/src/settingscache.h endif()
../cockatrice/src/settings/carddatabasesettings.h
)
ELSEIF(Qt5_FOUND)
Qt5_WRAP_CPP(dbconverter_SOURCES
../cockatrice/src/settingscache.h
../cockatrice/src/settings/carddatabasesettings.h
)
ENDIF()
# Build servatrice binary and link it # Build servatrice binary and link it
ADD_EXECUTABLE(dbconverter MACOSX_BUNDLE ${dbconverter_SOURCES} ${dbconverter_MOC_SRCS}) add_executable(dbconverter MACOSX_BUNDLE ${dbconverter_MOC_SRCS} ${dbconverter_SOURCES})
TARGET_LINK_LIBRARIES(dbconverter ${DB_CONVERTER_QT_MODULES}) target_link_libraries(dbconverter ${DB_CONVERTER_QT_MODULES})
# install rules # install rules
if(UNIX) if(UNIX)
@ -43,13 +36,13 @@ if(UNIX)
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}) set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
INSTALL(TARGETS dbconverter BUNDLE DESTINATION ./) install(TARGETS dbconverter BUNDLE DESTINATION ./)
else() else()
# Assume linux # Assume linux
INSTALL(TARGETS dbconverter RUNTIME DESTINATION bin/) install(TARGETS dbconverter RUNTIME DESTINATION bin/)
endif() endif()
elseif(WIN32) elseif(WIN32)
INSTALL(TARGETS dbconverter RUNTIME DESTINATION ./) install(TARGETS dbconverter RUNTIME DESTINATION ./)
endif() endif()
if(APPLE) if(APPLE)
@ -58,26 +51,35 @@ if(APPLE)
set(qtconf_dest_dir dbconverter.app/Contents/Resources) set(qtconf_dest_dir dbconverter.app/Contents/Resources)
# Qt plugins: platforms # Qt plugins: platforms
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING FILES_MATCHING
PATTERN "*.dSYM" EXCLUDE PATTERN "*.dSYM" EXCLUDE
PATTERN "*_debug.dylib" EXCLUDE PATTERN "*_debug.dylib" EXCLUDE
PATTERN "platforms/*.dylib" PATTERN "platforms/*.dylib"
) )
install(CODE " install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins Plugins = Plugins
Translations = Resources/translations\") Translations = Resources/translations\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
install(CODE " install(
CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/dbconverter.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/dbconverter.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
endif() endif()
if(WIN32) if(WIN32)
@ -85,26 +87,42 @@ if(WIN32)
set(plugin_dest_dir Plugins) set(plugin_dest_dir Plugins)
set(qtconf_dest_dir .) set(qtconf_dest_dir .)
install(DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" DESTINATION ./ FILES_MATCHING PATTERN "*.dll") install(
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"
DESTINATION ./
FILES_MATCHING
PATTERN "*.dll"
)
# Qt plugins: platforms # Qt plugins: platforms
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime FILES_MATCHING install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING
PATTERN "platforms/qdirect2d.dll" PATTERN "platforms/qdirect2d.dll"
PATTERN "platforms/qminimal.dll" PATTERN "platforms/qminimal.dll"
PATTERN "platforms/qoffscreen.dll" PATTERN "platforms/qoffscreen.dll"
PATTERN "platforms/qwindows.dll") PATTERN "platforms/qwindows.dll"
)
install(CODE " install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins Plugins = Plugins
Translations = Resources/translations\") Translations = Resources/translations\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
install(CODE " install(
CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\")
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/dbconverter.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/dbconverter.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
endif() endif()

View file

@ -5,7 +5,10 @@
project(Oracle VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") project(Oracle VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
# paths # paths
set(DESKTOPDIR share/applications CACHE STRING "path to .desktop files") set(DESKTOPDIR
share/applications
CACHE STRING "path to .desktop files"
)
set(oracle_SOURCES set(oracle_SOURCES
src/main.cpp src/main.cpp
@ -35,11 +38,11 @@ set(oracle_SOURCES
set(oracle_RESOURCES oracle.qrc) set(oracle_RESOURCES oracle.qrc)
if(UPDATE_TRANSLATIONS) if(UPDATE_TRANSLATIONS)
FILE(GLOB_RECURSE translate_oracle_SRCS src/*.cpp src/*.h ../cockatrice/src/settingscache.cpp) file(GLOB_RECURSE translate_oracle_SRCS src/*.cpp src/*.h ../cockatrice/src/settingscache.cpp)
SET(translate_SRCS ${translate_oracle_SRCS}) set(translate_SRCS ${translate_oracle_SRCS})
SET(oracle_TS "${CMAKE_CURRENT_SOURCE_DIR}/oracle_en@source.ts") set(oracle_TS "${CMAKE_CURRENT_SOURCE_DIR}/oracle_en@source.ts")
else() else()
FILE(GLOB oracle_TS "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts") file(GLOB oracle_TS "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts")
endif(UPDATE_TRANSLATIONS) endif(UPDATE_TRANSLATIONS)
if(WIN32) if(WIN32)
@ -48,43 +51,40 @@ endif(WIN32)
if(APPLE) if(APPLE)
set(MACOSX_BUNDLE_ICON_FILE appicon.icns) set(MACOSX_BUNDLE_ICON_FILE appicon.icns)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources
)
set(oracle_SOURCES ${oracle_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns) set(oracle_SOURCES ${oracle_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
endif(APPLE) endif(APPLE)
if(Qt6_FOUND) if(Qt6_FOUND)
Qt6_ADD_RESOURCES(oracle_RESOURCES_RCC ${oracle_RESOURCES}) qt6_add_resources(oracle_RESOURCES_RCC ${oracle_RESOURCES})
elseif(Qt5_FOUND) elseif(Qt5_FOUND)
Qt5_ADD_RESOURCES(oracle_RESOURCES_RCC ${oracle_RESOURCES}) qt5_add_resources(oracle_RESOURCES_RCC ${oracle_RESOURCES})
endif() endif()
INCLUDE_DIRECTORIES(../cockatrice/src) include_directories(../cockatrice/src)
# Libz is required to support zipped files # Libz is required to support zipped files
FIND_PACKAGE(ZLIB) find_package(ZLIB)
if(ZLIB_FOUND) if(ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) include_directories(${ZLIB_INCLUDE_DIRS})
ADD_DEFINITIONS("-DHAS_ZLIB") add_definitions("-DHAS_ZLIB")
set(oracle_SOURCES ${oracle_SOURCES} set(oracle_SOURCES ${oracle_SOURCES} src/zip/unzip.cpp src/zip/zipglobal.cpp)
src/zip/unzip.cpp
src/zip/zipglobal.cpp
)
else() else()
MESSAGE(STATUS "Oracle: zlib not found; ZIP support disabled") message(STATUS "Oracle: zlib not found; ZIP support disabled")
endif() endif()
# LibLZMA is required to support xz files # LibLZMA is required to support xz files
FIND_PACKAGE(LibLZMA) find_package(LibLZMA)
if(LIBLZMA_FOUND) if(LIBLZMA_FOUND)
INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) include_directories(${LIBLZMA_INCLUDE_DIRS})
ADD_DEFINITIONS("-DHAS_LZMA") add_definitions("-DHAS_LZMA")
set(oracle_SOURCES ${oracle_SOURCES} set(oracle_SOURCES ${oracle_SOURCES} src/lzma/decompress.cpp)
src/lzma/decompress.cpp
)
else() else()
MESSAGE(STATUS "Oracle: LibLZMA not found; xz support disabled") message(STATUS "Oracle: LibLZMA not found; xz support disabled")
endif() endif()
set(ORACLE_MAC_QM_INSTALL_DIR "oracle.app/Contents/Resources/translations") set(ORACLE_MAC_QM_INSTALL_DIR "oracle.app/Contents/Resources/translations")
@ -93,7 +93,15 @@ set(ORACLE_WIN32_QM_INSTALL_DIR "translations")
if(Qt6_FOUND) if(Qt6_FOUND)
# Qt6 Translations are linked after the executable is created in manual mode # Qt6 Translations are linked after the executable is created in manual mode
qt6_add_executable(oracle WIN32 MACOSX_BUNDLE ${oracle_SOURCES} ${oracle_RESOURCES_RCC} ${oracle_MOC_SRCS} MANUAL_FINALIZATION) qt6_add_executable(
oracle
WIN32
MACOSX_BUNDLE
${oracle_SOURCES}
${oracle_RESOURCES_RCC}
${oracle_MOC_SRCS}
MANUAL_FINALIZATION
)
elseif(Qt5_FOUND) elseif(Qt5_FOUND)
# Qt5 Translations need to be linked at executable creation time # Qt5 Translations need to be linked at executable creation time
if(Qt5LinguistTools_FOUND) if(Qt5LinguistTools_FOUND)
@ -103,7 +111,7 @@ elseif(Qt5_FOUND)
qt5_add_translation(oracle_QM ${oracle_TS}) qt5_add_translation(oracle_QM ${oracle_TS})
endif() endif()
endif() endif()
add_executable(oracle WIN32 MACOSX_BUNDLE ${oracle_SOURCES} ${oracle_QM} ${oracle_RESOURCES_RCC} ${oracle_MOC_SRCS}) add_executable(oracle WIN32 MACOSX_BUNDLE ${oracle_MOC_SRCS} ${oracle_QM} ${oracle_RESOURCES_RCC} ${oracle_SOURCES})
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
install(FILES ${oracle_QM} DESTINATION ${ORACLE_MAC_QM_INSTALL_DIR}) install(FILES ${oracle_QM} DESTINATION ${ORACLE_MAC_QM_INSTALL_DIR})
@ -115,14 +123,14 @@ elseif(Qt5_FOUND)
endif() endif()
endif() endif()
TARGET_LINK_LIBRARIES(oracle PUBLIC ${ORACLE_QT_MODULES}) target_link_libraries(oracle PUBLIC ${ORACLE_QT_MODULES})
if(ZLIB_FOUND) if(ZLIB_FOUND)
TARGET_LINK_LIBRARIES(oracle PUBLIC ${ZLIB_LIBRARIES}) target_link_libraries(oracle PUBLIC ${ZLIB_LIBRARIES})
endif() endif()
if(LIBLZMA_FOUND) if(LIBLZMA_FOUND)
TARGET_LINK_LIBRARIES(oracle PUBLIC ${LIBLZMA_LIBRARIES}) target_link_libraries(oracle PUBLIC ${LIBLZMA_LIBRARIES})
endif() endif()
if(UNIX) if(UNIX)
@ -135,20 +143,20 @@ if(UNIX)
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
set_target_properties(oracle PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/Info.plist) set_target_properties(oracle PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/Info.plist)
INSTALL(TARGETS oracle BUNDLE DESTINATION ./) install(TARGETS oracle BUNDLE DESTINATION ./)
else() else()
# Assume linux # Assume linux
INSTALL(TARGETS oracle RUNTIME DESTINATION bin/) install(TARGETS oracle RUNTIME DESTINATION bin/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/oracle.png DESTINATION ${ICONDIR}/hicolor/48x48/apps) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/oracle.png DESTINATION ${ICONDIR}/hicolor/48x48/apps)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/oracle.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/oracle.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps)
endif() endif()
elseif(WIN32) elseif(WIN32)
INSTALL(TARGETS oracle RUNTIME DESTINATION ./) install(TARGETS oracle RUNTIME DESTINATION ./)
endif() endif()
IF (NOT WIN32 AND NOT APPLE) if(NOT WIN32 AND NOT APPLE)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/oracle.desktop DESTINATION ${DESKTOPDIR}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/oracle.desktop DESTINATION ${DESKTOPDIR})
ENDIF (NOT WIN32 AND NOT APPLE) endif(NOT WIN32 AND NOT APPLE)
if(APPLE) if(APPLE)
# these needs to be relative to CMAKE_INSTALL_PREFIX # these needs to be relative to CMAKE_INSTALL_PREFIX
@ -156,7 +164,10 @@ if(APPLE)
set(qtconf_dest_dir oracle.app/Contents/Resources) set(qtconf_dest_dir oracle.app/Contents/Resources)
# Qt plugins: iconengines, platforms, styles, tls (Qt6) # Qt plugins: iconengines, platforms, styles, tls (Qt6)
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING FILES_MATCHING
PATTERN "*.dSYM" EXCLUDE PATTERN "*.dSYM" EXCLUDE
PATTERN "*_debug.dylib" EXCLUDE PATTERN "*_debug.dylib" EXCLUDE
@ -166,19 +177,25 @@ if(APPLE)
PATTERN "tls/*.dylib" PATTERN "tls/*.dylib"
) )
install(CODE " install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins Plugins = Plugins
Translations = Resources/translations\") Translations = Resources/translations\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
install(CODE " install(
CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
endif() endif()
if(WIN32) if(WIN32)
@ -187,10 +204,19 @@ if(WIN32)
set(qtconf_dest_dir .) set(qtconf_dest_dir .)
list(APPEND libSearchDirs ${QT_LIBRARY_DIR}) list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
install(DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" DESTINATION ./ FILES_MATCHING PATTERN "*.dll") install(
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"
DESTINATION ./
FILES_MATCHING
PATTERN "*.dll"
)
# Qt plugins: iconengines, platforms, styles, tls (Qt6) # Qt plugins: iconengines, platforms, styles, tls (Qt6)
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime FILES_MATCHING install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING
PATTERN "iconengines/qsvgicon.dll" PATTERN "iconengines/qsvgicon.dll"
PATTERN "platforms/qdirect2d.dll" PATTERN "platforms/qdirect2d.dll"
PATTERN "platforms/qminimal.dll" PATTERN "platforms/qminimal.dll"
@ -202,27 +228,42 @@ if(WIN32)
PATTERN "styles/qwindowsvistastyle.dll" PATTERN "styles/qwindowsvistastyle.dll"
PATTERN "tls/qcertonlybackend.dll" PATTERN "tls/qcertonlybackend.dll"
PATTERN "tls/qopensslbackend.dll" PATTERN "tls/qopensslbackend.dll"
PATTERN "tls/qschannelbackend.dll") PATTERN "tls/qschannelbackend.dll"
)
install(CODE " install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins Plugins = Plugins
Translations = Resources/translations\") Translations = Resources/translations\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
install(CODE " install(
CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\")
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Oracle.exe\" \"\${QTPLUGINS}\" \"${libSearchDirs}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Oracle.exe\" \"\${QTPLUGINS}\" \"${libSearchDirs}\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
endif() endif()
if(Qt6LinguistTools_FOUND) if(Qt6LinguistTools_FOUND)
#Qt6 Translations happen after the executable is built up # Qt6 Translations happen after the executable is built up
if(UPDATE_TRANSLATIONS) if(UPDATE_TRANSLATIONS)
qt6_add_translations(oracle TS_FILES ${oracle_TS} SOURCES ${translate_SRCS} QM_FILES_OUTPUT_VARIABLE oracle_QM) qt6_add_translations(
oracle
TS_FILES
${oracle_TS}
SOURCES
${translate_SRCS}
QM_FILES_OUTPUT_VARIABLE
oracle_QM
)
else() else()
qt6_add_translations(oracle TS_FILES ${oracle_TS} QM_FILES_OUTPUT_VARIABLE oracle_QM) qt6_add_translations(oracle TS_FILES ${oracle_TS} QM_FILES_OUTPUT_VARIABLE oracle_QM)
endif() endif()

View file

@ -2,9 +2,9 @@
# #
# provides the servatrice binary # provides the servatrice binary
PROJECT(Servatrice VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") project(Servatrice VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
SET(servatrice_SOURCES set(servatrice_SOURCES
src/main.cpp src/main.cpp
src/servatrice.cpp src/servatrice.cpp
src/servatrice_connection_pool.cpp src/servatrice_connection_pool.cpp
@ -34,60 +34,80 @@ if(CMAKE_HOST_SYSTEM MATCHES "FreeBSD")
set(SYSTEM_LIBRARIES ${EXECINFO_LIBRARY} ${SYSTEM_LIBRARIES}) set(SYSTEM_LIBRARIES ${EXECINFO_LIBRARY} ${SYSTEM_LIBRARIES})
endif() endif()
if(APPLE) if(APPLE)
set(MACOSX_BUNDLE_ICON_FILE appicon.icns) set(MACOSX_BUNDLE_ICON_FILE appicon.icns)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources
)
set(servatrice_SOURCES ${servatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns) set(servatrice_SOURCES ${servatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
ENDIF(APPLE) endif(APPLE)
IF(Qt6_FOUND) if(Qt6_FOUND)
Qt6_ADD_RESOURCES(servatrice_RESOURCES_RCC ${servatrice_RESOURCES}) qt6_add_resources(servatrice_RESOURCES_RCC ${servatrice_RESOURCES})
ELSEIF(Qt5_FOUND) elseif(Qt5_FOUND)
Qt5_ADD_RESOURCES(servatrice_RESOURCES_RCC ${servatrice_RESOURCES}) qt5_add_resources(servatrice_RESOURCES_RCC ${servatrice_RESOURCES})
ENDIF() endif()
SET(QT_DONT_USE_QTGUI TRUE) set(QT_DONT_USE_QTGUI TRUE)
# Mysql connector # Mysql connector
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
SET(MYSQLCLIENT_DEFAULT_PATHS "/usr/local/lib" "/opt/local/lib/mysql55/mysql/" "/opt/local/lib/mysql56/mysql/") set(MYSQLCLIENT_DEFAULT_PATHS "/usr/local/lib" "/opt/local/lib/mysql55/mysql/" "/opt/local/lib/mysql56/mysql/")
else() else()
SET(MYSQLCLIENT_DEFAULT_PATHS "/usr/lib64" "/usr/local/lib64" "/usr/lib" "/usr/local/lib") set(MYSQLCLIENT_DEFAULT_PATHS "/usr/lib64" "/usr/local/lib64" "/usr/lib" "/usr/local/lib")
endif() endif()
elseif(WIN32) elseif(WIN32)
SET(MYSQLCLIENT_DEFAULT_PATHS "C:\\Program Files\\MySQL\\MySQL Server 5.7\\lib" "C:\\Program Files (x86)\\MySQL\\MySQL Server 5.7\\lib") set(MYSQLCLIENT_DEFAULT_PATHS "C:\\Program Files\\MySQL\\MySQL Server 5.7\\lib"
"C:\\Program Files (x86)\\MySQL\\MySQL Server 5.7\\lib"
)
endif() endif()
find_library(MYSQL_CLIENT_LIBRARIES NAMES mysqlclient PATHS ${MYSQLCLIENT_DEFAULT_PATHS} PATH_SUFFIXES mysql mariadb) find_library(
MYSQL_CLIENT_LIBRARIES
NAMES mysqlclient
PATHS ${MYSQLCLIENT_DEFAULT_PATHS}
PATH_SUFFIXES mysql mariadb
)
if(${MYSQL_CLIENT_LIBRARIES} MATCHES "NOTFOUND") if(${MYSQL_CLIENT_LIBRARIES} MATCHES "NOTFOUND")
set(MYSQLCLIENT_FOUND FALSE CACHE INTERNAL "") set(MYSQLCLIENT_FOUND
MESSAGE(STATUS "MySQL connector NOT FOUND: Servatrice won't be able to connect to a MySQL server") FALSE
CACHE INTERNAL ""
)
message(STATUS "MySQL connector NOT FOUND: Servatrice won't be able to connect to a MySQL server")
unset(MYSQL_CLIENT_LIBRARIES) unset(MYSQL_CLIENT_LIBRARIES)
else() else()
set(MYSQLCLIENT_FOUND TRUE CACHE INTERNAL "") set(MYSQLCLIENT_FOUND
TRUE
CACHE INTERNAL ""
)
get_filename_component(MYSQLCLIENT_LIBRARY_DIR ${MYSQL_CLIENT_LIBRARIES} PATH) get_filename_component(MYSQLCLIENT_LIBRARY_DIR ${MYSQL_CLIENT_LIBRARIES} PATH)
MESSAGE(STATUS "Found MySQL connector at: ${MYSQL_CLIENT_LIBRARIES}") message(STATUS "Found MySQL connector at: ${MYSQL_CLIENT_LIBRARIES}")
endif() endif()
# Declare path variables # Declare path variables
set(ICONDIR share/icons CACHE STRING "icon dir") set(ICONDIR
set(DESKTOPDIR share/applications CACHE STRING "desktop file destination") share/icons
CACHE STRING "icon dir"
)
set(DESKTOPDIR
share/applications
CACHE STRING "desktop file destination"
)
# Include directories # Include directories
INCLUDE_DIRECTORIES(../common) include_directories(../common)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) include_directories(${PROTOBUF_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../common) include_directories(${CMAKE_CURRENT_BINARY_DIR}/../common)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Build servatrice binary and link it # Build servatrice binary and link it
ADD_EXECUTABLE(servatrice MACOSX_BUNDLE ${servatrice_SOURCES} ${servatrice_RESOURCES_RCC} ${servatrice_MOC_SRCS}) add_executable(servatrice MACOSX_BUNDLE ${servatrice_MOC_SRCS} ${servatrice_RESOURCES_RCC} ${servatrice_SOURCES})
if(CMAKE_HOST_SYSTEM MATCHES "FreeBSD") if(CMAKE_HOST_SYSTEM MATCHES "FreeBSD")
TARGET_LINK_LIBRARIES(servatrice cockatrice_common Threads::Threads ${SERVATRICE_QT_MODULES} ${LIBEXECINFO_LIBRARY}) target_link_libraries(servatrice cockatrice_common Threads::Threads ${SERVATRICE_QT_MODULES} ${LIBEXECINFO_LIBRARY})
else() else()
TARGET_LINK_LIBRARIES(servatrice cockatrice_common Threads::Threads ${SERVATRICE_QT_MODULES}) target_link_libraries(servatrice cockatrice_common Threads::Threads ${SERVATRICE_QT_MODULES})
endif() endif()
# install rules # install rules
@ -100,23 +120,23 @@ if(UNIX)
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}) set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
INSTALL(TARGETS servatrice BUNDLE DESTINATION ./) install(TARGETS servatrice BUNDLE DESTINATION ./)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.ini.example DESTINATION ./servatrice.app/Contents/Resources/) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.ini.example DESTINATION ./servatrice.app/Contents/Resources/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.sql DESTINATION ./servatrice.app/Contents/Resources/) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.sql DESTINATION ./servatrice.app/Contents/Resources/)
else() else()
# Assume linux # Assume linux
INSTALL(TARGETS servatrice RUNTIME DESTINATION bin/) install(TARGETS servatrice RUNTIME DESTINATION bin/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.ini.example DESTINATION share/servatrice/) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.ini.example DESTINATION share/servatrice/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.sql DESTINATION share/servatrice/) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.sql DESTINATION share/servatrice/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/servatrice.png DESTINATION ${ICONDIR}/hicolor/48x48/apps) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/servatrice.png DESTINATION ${ICONDIR}/hicolor/48x48/apps)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/servatrice.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/servatrice.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.desktop DESTINATION ${DESKTOPDIR}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.desktop DESTINATION ${DESKTOPDIR})
endif() endif()
elseif(WIN32) elseif(WIN32)
INSTALL(TARGETS servatrice RUNTIME DESTINATION ./) install(TARGETS servatrice RUNTIME DESTINATION ./)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.ini.example DESTINATION ./) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.ini.example DESTINATION ./)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.sql DESTINATION ./) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.sql DESTINATION ./)
endif() endif()
if(APPLE) if(APPLE)
@ -125,7 +145,10 @@ if(APPLE)
set(qtconf_dest_dir servatrice.app/Contents/Resources) set(qtconf_dest_dir servatrice.app/Contents/Resources)
# Qt plugins: platforms, sqldrivers/mysql, tls (Qt6) # Qt plugins: platforms, sqldrivers/mysql, tls (Qt6)
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING FILES_MATCHING
PATTERN "*.dSYM" EXCLUDE PATTERN "*.dSYM" EXCLUDE
PATTERN "*_debug.dylib" EXCLUDE PATTERN "*_debug.dylib" EXCLUDE
@ -134,19 +157,25 @@ if(APPLE)
PATTERN "tls/*.dylib" PATTERN "tls/*.dylib"
) )
install(CODE " install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins Plugins = Plugins
Translations = Resources/translations\") Translations = Resources/translations\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
install(CODE " install(
CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
endif() endif()
if(WIN32) if(WIN32)
@ -154,10 +183,19 @@ if(WIN32)
set(plugin_dest_dir Plugins) set(plugin_dest_dir Plugins)
set(qtconf_dest_dir .) set(qtconf_dest_dir .)
install(DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" DESTINATION ./ FILES_MATCHING PATTERN "*.dll") install(
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"
DESTINATION ./
FILES_MATCHING
PATTERN "*.dll"
)
# Qt plugins: platforms, sqldrivers, tls (Qt6) # Qt plugins: platforms, sqldrivers, tls (Qt6)
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime FILES_MATCHING install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING
PATTERN "platforms/qdirect2d.dll" PATTERN "platforms/qdirect2d.dll"
PATTERN "platforms/qminimal.dll" PATTERN "platforms/qminimal.dll"
PATTERN "platforms/qoffscreen.dll" PATTERN "platforms/qoffscreen.dll"
@ -167,19 +205,26 @@ if(WIN32)
PATTERN "tls/qschannelbackend.dll" PATTERN "tls/qschannelbackend.dll"
PATTERN "sqldrivers/qsqlite.dll" PATTERN "sqldrivers/qsqlite.dll"
PATTERN "sqldrivers/qsqlodbc.dll" PATTERN "sqldrivers/qsqlodbc.dll"
PATTERN "sqldrivers/qsqlpsql.dll") PATTERN "sqldrivers/qsqlpsql.dll"
)
install(CODE " install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins Plugins = Plugins
Translations = Resources/translations\") Translations = Resources/translations\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
install(CODE " install(
CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\")
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Servatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Servatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\")
" COMPONENT Runtime) "
COMPONENT Runtime
)
endif() endif()

View file

@ -15,29 +15,27 @@ add_executable(password_hash_test password_hash_test.cpp)
find_package(GTest) find_package(GTest)
if(NOT GTEST_FOUND) if(NOT GTEST_FOUND)
IF(NOT EXISTS "${CMAKE_BINARY_DIR}/gtest-build") if(NOT EXISTS "${CMAKE_BINARY_DIR}/gtest-build")
message(STATUS "Downloading googletest") message(STATUS "Downloading googletest")
configure_file("${CMAKE_SOURCE_DIR}/cmake/gtest-CMakeLists.txt.in" "${CMAKE_BINARY_DIR}/gtest-download/CMakeLists.txt") configure_file(
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . "${CMAKE_SOURCE_DIR}/cmake/gtest-CMakeLists.txt.in" "${CMAKE_BINARY_DIR}/gtest-download/CMakeLists.txt"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gtest-download ) )
execute_process(COMMAND ${CMAKE_COMMAND} --build . execute_process(
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gtest-download ) COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gtest-download
ELSE() )
execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gtest-download)
else()
message(STATUS "GoogleTest directory exists") message(STATUS "GoogleTest directory exists")
ENDIF() endif()
# Add gtest directly to our build # Add gtest directly to our build
add_subdirectory(${CMAKE_BINARY_DIR}/gtest-src add_subdirectory(${CMAKE_BINARY_DIR}/gtest-src ${CMAKE_BINARY_DIR}/gtest-build EXCLUDE_FROM_ALL)
${CMAKE_BINARY_DIR}/gtest-build
EXCLUDE_FROM_ALL )
# Add the gtest include directory, since gtest # Add the gtest include directory, since gtest doesn't add that dependency to its gtest target
# doesn't add that dependency to its gtest target target_include_directories(gtest INTERFACE "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/gtest-src/include>")
target_include_directories(gtest INTERFACE
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/gtest-src/include>" )
SET(GTEST_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/gtest-src/include") set(GTEST_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/gtest-src/include")
SET(GTEST_BOTH_LIBRARIES gtest) set(GTEST_BOTH_LIBRARIES gtest)
add_dependencies(dummy_test gtest) add_dependencies(dummy_test gtest)
add_dependencies(expression_test gtest) add_dependencies(expression_test gtest)
add_dependencies(test_age_formatting gtest) add_dependencies(test_age_formatting gtest)

View file

@ -1,43 +1,41 @@
ADD_DEFINITIONS("-DCARDDB_DATADIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data/\"") add_definitions("-DCARDDB_DATADIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data/\"")
SET(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Concurrent ${COCKATRICE_QT_VERSION_NAME}::Network ${COCKATRICE_QT_VERSION_NAME}::Widgets ${COCKATRICE_QT_VERSION_NAME}::Svg) set(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Concurrent ${COCKATRICE_QT_VERSION_NAME}::Network
${COCKATRICE_QT_VERSION_NAME}::Widgets ${COCKATRICE_QT_VERSION_NAME}::Svg
)
IF(Qt6_FOUND) if(Qt6_FOUND)
QT6_WRAP_CPP(MOCKS_SOURCES qt6_wrap_cpp(MOCKS_SOURCES ../../cockatrice/src/settingscache.h ../../cockatrice/src/settings/carddatabasesettings.h)
../../cockatrice/src/settingscache.h elseif(Qt5_FOUND)
../../cockatrice/src/settings/carddatabasesettings.h qt5_wrap_cpp(MOCKS_SOURCES ../../cockatrice/src/settingscache.h ../../cockatrice/src/settings/carddatabasesettings.h)
) endif()
ELSEIF(Qt5_FOUND)
QT5_WRAP_CPP(MOCKS_SOURCES
../../cockatrice/src/settingscache.h
../../cockatrice/src/settings/carddatabasesettings.h
)
ENDIF()
add_executable(carddatabase_test add_executable(
carddatabase_test
${MOCKS_SOURCES}
${VERSION_STRING_CPP}
../../cockatrice/src/carddatabase.cpp
../../cockatrice/src/carddbparser/carddatabaseparser.cpp
../../cockatrice/src/carddbparser/cockatricexml3.cpp
../../cockatrice/src/carddbparser/cockatricexml4.cpp
../../cockatrice/src/settings/settingsmanager.cpp
carddatabase_test.cpp carddatabase_test.cpp
mocks.cpp mocks.cpp
)
add_executable(
filter_string_test
${MOCKS_SOURCES}
${VERSION_STRING_CPP}
../../cockatrice/src/carddatabase.cpp ../../cockatrice/src/carddatabase.cpp
../../cockatrice/src/carddbparser/carddatabaseparser.cpp ../../cockatrice/src/carddbparser/carddatabaseparser.cpp
../../cockatrice/src/carddbparser/cockatricexml3.cpp ../../cockatrice/src/carddbparser/cockatricexml3.cpp
../../cockatrice/src/carddbparser/cockatricexml4.cpp ../../cockatrice/src/carddbparser/cockatricexml4.cpp
../../cockatrice/src/cardfilter.cpp
../../cockatrice/src/filter_string.cpp
../../cockatrice/src/filtertree.cpp
../../cockatrice/src/settings/settingsmanager.cpp ../../cockatrice/src/settings/settingsmanager.cpp
${VERSION_STRING_CPP}
${MOCKS_SOURCES}
)
add_executable(filter_string_test
filter_string_test.cpp filter_string_test.cpp
mocks.cpp mocks.cpp
../../cockatrice/src/filter_string.cpp
../../cockatrice/src/cardfilter.cpp
../../cockatrice/src/filtertree.cpp
../../cockatrice/src/carddatabase.cpp
../../cockatrice/src/carddbparser/carddatabaseparser.cpp
../../cockatrice/src/carddbparser/cockatricexml3.cpp
../../cockatrice/src/carddbparser/cockatricexml4.cpp
../../cockatrice/src/settings/settingsmanager.cpp
${VERSION_STRING_CPP}
${MOCKS_SOURCES}
) )
if(NOT GTEST_FOUND) if(NOT GTEST_FOUND)
add_dependencies(carddatabase_test gtest) add_dependencies(carddatabase_test gtest)
@ -47,6 +45,5 @@ endif()
target_link_libraries(carddatabase_test Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES}) target_link_libraries(carddatabase_test Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES})
target_link_libraries(filter_string_test Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES}) target_link_libraries(filter_string_test Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES})
add_test(NAME carddatabase_test COMMAND carddatabase_test) add_test(NAME carddatabase_test COMMAND carddatabase_test)
add_test(NAME filter_string_test COMMAND filter_string_test) add_test(NAME filter_string_test COMMAND filter_string_test)

View file

@ -1,15 +1,17 @@
ADD_DEFINITIONS("-DCARDDB_DATADIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data/\"") add_definitions("-DCARDDB_DATADIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data/\"")
add_executable(loading_from_clipboard_test add_executable(
loading_from_clipboard_test.cpp loading_from_clipboard_test ../../common/decklist.cpp clipboard_testing.cpp loading_from_clipboard_test.cpp
clipboard_testing.cpp )
../../common/decklist.cpp
)
if(NOT GTEST_FOUND) if(NOT GTEST_FOUND)
add_dependencies(loading_from_clipboard_test gtest) add_dependencies(loading_from_clipboard_test gtest)
endif() endif()
SET(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Concurrent ${COCKATRICE_QT_VERSION_NAME}::Network ${COCKATRICE_QT_VERSION_NAME}::Widgets) set(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Concurrent ${COCKATRICE_QT_VERSION_NAME}::Network
${COCKATRICE_QT_VERSION_NAME}::Widgets
)
target_link_libraries(loading_from_clipboard_test cockatrice_common Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES}) target_link_libraries(
loading_from_clipboard_test cockatrice_common Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES}
)
add_test(NAME loading_from_clipboard_test COMMAND loading_from_clipboard_test) add_test(NAME loading_from_clipboard_test COMMAND loading_from_clipboard_test)