mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-25 12:18:25 -05:00
cmake static build support
For the static build is always used inline constants. For the shared build is used extern constants by default and this default can be overridden by a new cmake option INLINE_CONSTANTS. - renamed project folder tests/utils to tests/TinyUtils - bugfix missed INTERFACE TINYUTILS_LINKING_SHARED in TinyUtils target - renamed export macro defines for TinyUtils from UTILS_ to TINYUTILS_ - renamed utils_global.hpp to export.hpp in TinyUtils - added WINVER macro - updated NTDDI_WINNT and similar macros - removed TINYORM_LINKING_SHARED from TinyTestCommon.cmake, it is in the INTERFACE from TinyOrm target
This commit is contained in:
@@ -63,6 +63,11 @@ feature_option(BUILD_SHARED_LIBS
|
||||
feature_option(BUILD_TESTS
|
||||
"Build Qt tests" OFF
|
||||
)
|
||||
feature_option_dependent(INLINE_CONSTANTS
|
||||
"Use inline constants instead of extern constants in the shared build. \
|
||||
OFF is highly recommended for the shared build; is always ON for the static build" OFF
|
||||
"BUILD_SHARED_LIBS" ON
|
||||
)
|
||||
# TODO make it also dependend on NOT isMultiConfig silverqx
|
||||
# Depends on tiny_init_cmake_variables_pre() call
|
||||
feature_option_dependent(MATCH_EQUAL_EXPORTED_BUILDTREE
|
||||
@@ -173,6 +178,13 @@ if(BUILD_SHARED_LIBS)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Specifies which global constant types will be used
|
||||
if(TINY_EXTERN_CONSTANTS)
|
||||
target_compile_definitions(${TinyOrm_target} PUBLIC TINYORM_EXTERN_CONSTANTS)
|
||||
else()
|
||||
target_compile_definitions(${TinyOrm_target} PUBLIC TINYORM_INLINE_CONSTANTS)
|
||||
endif()
|
||||
|
||||
# Enable code needed by tests, eg. connection overriding in the Model
|
||||
if(BUILD_TESTS)
|
||||
target_compile_definitions(${TinyOrm_target} PUBLIC TINYORM_TESTS_CODE)
|
||||
|
||||
@@ -94,7 +94,7 @@ function(target_optional_compile_definitions target scope)
|
||||
target_compile_definitions(${target} ${scope} ${TINY_DISABLED})
|
||||
endif()
|
||||
|
||||
if(${TINY_FEATURE})
|
||||
if(TINY_FEATURE)
|
||||
add_feature_info(${TINY_NAME} ${TINY_NAME} "${TINY_DESCRIPTION}")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -43,11 +43,13 @@ function(tiny_qt_common target)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_compile_definitions(${target} INTERFACE
|
||||
# All have to be defined because of checks at the beginning of <qt_windows.h>
|
||||
# Windows 10 1903 "19H1" - 0x0A000007
|
||||
NTDDI_VERSION=0x0A000007
|
||||
# Windows 10 - 0x0A00
|
||||
_WIN32_WINNT=0x0A00
|
||||
_WIN32_IE=0x0A00
|
||||
WINVER=_WIN32_WINNT_WIN10
|
||||
NTDDI_VERSION=NTDDI_WIN10_19H1
|
||||
_WIN32_WINNT=_WIN32_WINNT_WIN10
|
||||
# Internet Explorer 11
|
||||
_WIN32_IE=_WIN32_IE_IE110
|
||||
UNICODE _UNICODE
|
||||
# Exclude unneeded header files
|
||||
WIN32_LEAN_AND_MEAN
|
||||
|
||||
@@ -162,4 +162,13 @@ ${CMAKE_BINARY_DIR}/tests/auto/utils${TINY_PATH_SEPARATOR}$ENV{PATH}")
|
||||
"True when using a multi-configuration generator")
|
||||
unset(isMultiConfig)
|
||||
|
||||
# Specifies which global constant types will be used
|
||||
if(BUILD_SHARED_LIBS AND NOT INLINE_CONSTANTS)
|
||||
set(TINY_EXTERN_CONSTANTS ON CACHE INTERNAL
|
||||
"Determine whether the project will be built with extern constants")
|
||||
else()
|
||||
set(TINY_EXTERN_CONSTANTS OFF CACHE INTERNAL
|
||||
"Determine whether the project will be built with extern constants")
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
||||
@@ -2,7 +2,15 @@
|
||||
# Create header and source files lists and return them
|
||||
function(tiny_sources out_headers out_sources)
|
||||
|
||||
set(headers
|
||||
set(headers)
|
||||
|
||||
if(TINY_EXTERN_CONSTANTS)
|
||||
list(APPEND headers constants_extern.hpp)
|
||||
else()
|
||||
list(APPEND headers constants_inline.hpp)
|
||||
endif()
|
||||
|
||||
list(APPEND headers
|
||||
basegrammar.hpp
|
||||
concepts.hpp
|
||||
concerns/detectslostconnections.hpp
|
||||
@@ -82,12 +90,19 @@ function(tiny_sources out_headers out_sources)
|
||||
types/statementscounter.hpp
|
||||
utils/attribute.hpp
|
||||
utils/export.hpp
|
||||
utils/export_global.hpp
|
||||
utils/string.hpp
|
||||
utils/type.hpp
|
||||
version.hpp
|
||||
)
|
||||
|
||||
set(sources
|
||||
set(sources)
|
||||
|
||||
if(TINY_EXTERN_CONSTANTS)
|
||||
list(APPEND sources constants_extern.cpp)
|
||||
endif()
|
||||
|
||||
list(APPEND sources
|
||||
basegrammar.cpp
|
||||
concerns/detectslostconnections.cpp
|
||||
concerns/hasconnectionresolver.cpp
|
||||
@@ -96,7 +111,6 @@ function(tiny_sources out_headers out_sources)
|
||||
connectors/mysqlconnector.cpp
|
||||
connectors/postgresconnector.cpp
|
||||
connectors/sqliteconnector.cpp
|
||||
constants.cpp
|
||||
databaseconnection.cpp
|
||||
databasemanager.cpp
|
||||
db.cpp
|
||||
|
||||
@@ -39,7 +39,6 @@ function(tiny_configure_test name)
|
||||
PRIVATE
|
||||
PROJECT_TINYORM_TEST
|
||||
TINYORM_TESTS_CODE
|
||||
TINYORM_LINKING_SHARED
|
||||
)
|
||||
|
||||
target_include_directories(${name} PRIVATE
|
||||
|
||||
@@ -102,6 +102,7 @@ namespace Relations {
|
||||
// CUR qmake check generated resources tmp/ folder and build_pass() silverqx
|
||||
// CUR enable QT_ASCII_CAST_WARNINGS silverqx
|
||||
// CUR autoconfigure qmake with qmake/TinyOrm.pri and TINY_ROOT_DIR and TINY_TINYORM_BUILDS_DIR silverqx
|
||||
// CUR rename export_global.hpp to export_common.hpp silverqx
|
||||
/*! Base model class. */
|
||||
template<typename Derived, AllRelationsConcept ...AllRelations>
|
||||
class Model :
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
add_subdirectory(auto)
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(TinyUtils)
|
||||
|
||||
@@ -23,8 +23,8 @@ project(${TinyUtils_ns}
|
||||
|
||||
add_library(${TinyUtils_target}
|
||||
src/databases.hpp
|
||||
src/export.hpp
|
||||
src/fs.hpp
|
||||
src/utils_global.hpp
|
||||
src/version.hpp
|
||||
|
||||
src/databases.cpp
|
||||
@@ -69,7 +69,12 @@ target_include_directories(${TinyUtils_target} PUBLIC
|
||||
# ---
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(${TinyUtils_target} PRIVATE UTILS_BUILDING_SHARED)
|
||||
target_compile_definitions(${TinyUtils_target}
|
||||
PRIVATE
|
||||
TINYUTILS_BUILDING_SHARED
|
||||
INTERFACE
|
||||
TINYUTILS_LINKING_SHARED
|
||||
)
|
||||
endif()
|
||||
|
||||
# Windows resource and manifest files
|
||||
|
||||
Reference in New Issue
Block a user