From 0c20b47e2c82a2007aecc77d8014d45143147cd4 Mon Sep 17 00:00:00 2001 From: egorpugin Date: Tue, 27 Jan 2015 14:37:59 +0000 Subject: [PATCH] Improve Qt+MSVC build. Fix some messages. Crosscompiling improvements (add some defines). --- CMakeLists.txt | 61 +++++++++++++++++++++++-------- builds/cmake/BuildFunctions.cmake | 4 +- builds/cmake/Configure.cmake | 4 +- src/CMakeLists.txt | 30 ++++++--------- src/include/gen/autoconfig.h.in | 6 +++ 5 files changed, 67 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32055a040d..8ed5a05e0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,18 +2,18 @@ # firebird (trunk) # -############################################################################### +################################################################################ # # cmake settings # -############################################################################### +################################################################################ cmake_minimum_required(VERSION 2.8.8) # In-source builds are not possible and so disabled. if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR - "CMake generation for firebird is not possible within the source directory!" + "CMake generation for Firebird is not possible within the source directory!" "\n Remove the CMakeCache.txt file and try again from another folder, e.g.:" "\n " "\n rm CMakeCache.txt" @@ -35,15 +35,36 @@ endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake Targets") -############################################################################### +################################################################################ # # project settings # -############################################################################### +################################################################################ project("firebird" C CXX) -####################################### +######################################## +# build type settings +######################################## + +# Define build mode +if (NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build.") +endif() + +# Qt with MSVC does not have multiconfiguration option by default, +# so we create it. +set(DEFAULT_CONFIGURATION) + +# Set build types if none was specified +if (NOT DEFINED CMAKE_CONFIGURATION_TYPES) + set(CMAKE_CONFIGURATION_TYPES Debug Release MinSizeRel RelWithDebInfo) + set(DEFAULT_CONFIGURATION ${CMAKE_BUILD_TYPE}) +endif() + +######################################## +# Output directory settings +######################################## set(output_dir ${CMAKE_BINARY_DIR}/${PROJECT_NAME}) @@ -54,6 +75,13 @@ if (MSVC OR XCODE) set(output_dir ${output_dir}/$) endif() +if (MSVC AND DEFAULT_CONFIGURATION) + foreach(conf ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${conf} conf2) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${conf2} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DEFAULT_CONFIGURATION}) + endforeach() +endif() + if (XCODE) foreach(conf ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${conf} conf2) @@ -64,11 +92,11 @@ elseif (UNIX) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${output_dir}/bin) endif() -############################################################################### +################################################################################ # # configure # -############################################################################### +################################################################################ include(Configure) @@ -93,11 +121,11 @@ set(AUTOCONFIG_SRC ${CMAKE_SOURCE_DIR}/src/include/gen/autoconfig.h.in) set(AUTOCONFIG ${CMAKE_BINARY_DIR}/src/include/gen/autoconfig.h) configure_file(${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY) -############################################################################### +################################################################################ # # compiler & linker # -############################################################################### +################################################################################ add_definitions(-DDEV_BUILD) @@ -175,11 +203,11 @@ elseif (UNIX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") endif() -############################################################################### +################################################################################ # # pre build # -############################################################################### +################################################################################ if (WIN32) # icu @@ -228,12 +256,11 @@ if (UNIX) endforeach() endif() - -############################################################################### +################################################################################ # # build # -############################################################################### +################################################################################ include(BuildFunctions) @@ -272,10 +299,12 @@ file(GLOB libtommath_src "extern/libtommath/*.c" "extern/libtommath/*.h") add_library (libtommath ${libtommath_src}) project_group (libtommath Extern) +######################################## +# subdirectories ######################################## add_subdirectory("examples") add_subdirectory("src") -############################################################################### +################################################################################ diff --git a/builds/cmake/BuildFunctions.cmake b/builds/cmake/BuildFunctions.cmake index 56c48cba45..f45cb0f13e 100644 --- a/builds/cmake/BuildFunctions.cmake +++ b/builds/cmake/BuildFunctions.cmake @@ -27,7 +27,7 @@ function(set_output_directory target dir) set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${conf2} ${out}/${conf}/${dir}) endforeach() else() # single configuration - execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${out}/${dir}) + add_custom_command(TARGET ${target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${out}/${dir}) set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${out}/${dir}) set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${out}/${dir}) endif() @@ -103,7 +103,7 @@ function(epp_process type files) ) elseif ("${type}" STREQUAL "master") get_filename_component(file ${out} NAME) - set(dir ${dir}/${file}.d) + set(dir ${dir}/${file}.d) add_custom_command( OUTPUT ${out} DEPENDS ${in} databases diff --git a/builds/cmake/Configure.cmake b/builds/cmake/Configure.cmake index 9c7fe86f8e..1eec8be6cf 100644 --- a/builds/cmake/Configure.cmake +++ b/builds/cmake/Configure.cmake @@ -40,8 +40,8 @@ endfunction(check_functions) function(check_type_alignment type var) if (NOT DEFINED ${var}) check_c_source_runs("main(){struct s{char a;${type} b;};exit((int)&((struct s*)0)->b);}" ${var}) - #message("-- Performing Test ${var} - It's still OK.") - message("-- Performing Test ${var} - Success") + #message(STATUS "Performing Test ${var} - It's still OK.") + message(STATUS "Performing Test ${var} - Success") set(${var} ${${var}_EXITCODE} CACHE STRING "${type} alignment" FORCE) endif() endfunction(check_type_alignment) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8972c2fd1a..5a77afcbb0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,18 +92,22 @@ epp_process(master epp_master_files boot_gpre -n -m) # BUILD STEP databases ######################################## -set(databases_src - ${CMAKE_CURRENT_SOURCE_DIR}/dbs/security.sql +set(msgs_src ${CMAKE_CURRENT_SOURCE_DIR}/msgs/facilities2.sql ${CMAKE_CURRENT_SOURCE_DIR}/msgs/history2.sql ${CMAKE_CURRENT_SOURCE_DIR}/msgs/locales.sql ${CMAKE_CURRENT_SOURCE_DIR}/msgs/messages2.sql + ${CMAKE_CURRENT_SOURCE_DIR}/msgs/msg.sql ${CMAKE_CURRENT_SOURCE_DIR}/msgs/sqlstates.sql ${CMAKE_CURRENT_SOURCE_DIR}/msgs/symbols2.sql ${CMAKE_CURRENT_SOURCE_DIR}/msgs/system_errors2.sql ${CMAKE_CURRENT_SOURCE_DIR}/msgs/transmsgs.de_DE2.sql ${CMAKE_CURRENT_SOURCE_DIR}/msgs/transmsgs.fr_FR2.sql ) +set(databases_src + ${CMAKE_CURRENT_SOURCE_DIR}/dbs/security.sql + ${msgs_src} +) add_custom_command( OUTPUT security.fdb DEPENDS @@ -112,8 +116,8 @@ add_custom_command( VERBATIM # COMMAND ${CMAKE_COMMAND} -E remove security3.fdb - COMMAND ${CMAKE_COMMAND} -E echo "create database 'security3.fdb';" > create_db.sql - COMMAND boot_isql -q -i create_db.sql + COMMAND ${CMAKE_COMMAND} -E echo "create database 'security3.fdb';" > create_db_security3.sql + COMMAND boot_isql -q -i create_db_security3.sql COMMAND boot_isql -q security3.fdb -i ${CMAKE_CURRENT_SOURCE_DIR}/dbs/security.sql COMMAND ${CMAKE_COMMAND} -E copy_if_different security3.fdb security.fdb ) @@ -132,21 +136,11 @@ add_custom_command( VERBATIM DEPENDS boot_isql - metadata.fdb - security.fdb - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/facilities2.sql - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/history2.sql - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/locales.sql - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/messages2.sql - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/sqlstates.sql - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/symbols2.sql - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/system_errors2.sql - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/transmsgs.de_DE2.sql - ${CMAKE_CURRENT_SOURCE_DIR}/msgs/transmsgs.fr_FR2.sql + ${msgs_src} # COMMAND ${CMAKE_COMMAND} -E remove msg.fdb - COMMAND ${CMAKE_COMMAND} -E echo "create database 'msg.fdb';" > create_db.sql - COMMAND boot_isql -q -i create_db.sql + COMMAND ${CMAKE_COMMAND} -E echo "create database 'msg.fdb';" > create_db_msg.sql + COMMAND boot_isql -q -i create_db_msg.sql COMMAND ${isql_exec_msg}/msg.sql # COMMAND echo loading facilities @@ -774,7 +768,7 @@ if (WIN32) COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/extern/icu/icudt52l_empty.dat ${output_dir}/icudt52l_empty.dat ) - string(FIND ${CMAKE_EXE_LINKER_FLAGS} "/machine:x64" arch) + string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "/machine:x64" arch) if (NOT ${arch} EQUAL -1) set(arch "x64") else() diff --git a/src/include/gen/autoconfig.h.in b/src/include/gen/autoconfig.h.in index 5b0f167143..439a830d69 100644 --- a/src/include/gen/autoconfig.h.in +++ b/src/include/gen/autoconfig.h.in @@ -45,6 +45,9 @@ /* Define this if OS is AIX */ #cmakedefine AIX 1 +/* Define this if OS is ANDROID */ +#cmakedefine ANDROID 1 + /* Define this if OS is DARWIN */ #cmakedefine DARWIN 1 @@ -54,6 +57,9 @@ /* Define this if OS is HP-UX */ #cmakedefine HPUX 1 +/* Define this if OS is iOS */ +#cmakedefine IOS 1 + /* Define this if OS is Linux */ #cmakedefine LINUX 1