diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cfaefa617..9b6595ffaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,14 @@ # # firebird (trunk) # +# This file has following organization: +# 1. cmake settings +# 2. project settings +# 3. configure +# 4. compiler & linker settings +# 5. pre-build +# 6. build +# ################################################################################ # @@ -123,7 +131,7 @@ configure_file(${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY) ################################################################################ # -# compiler & linker +# compiler & linker settings # ################################################################################ @@ -205,7 +213,7 @@ endif() ################################################################################ # -# pre build +# pre-build # ################################################################################ @@ -291,7 +299,7 @@ if (NOT CMAKE_CROSSCOMPILING) add_executable (btyacc ${btyacc_src}) project_group (btyacc Extern) -set_output_directory (btyacc . FORCE) +set_output_directory (btyacc . CURRENT_DIR) endif() # if (NOT CMAKE_CROSSCOMPILING) @@ -313,4 +321,3 @@ add_subdirectory("examples") add_subdirectory("src") ################################################################################ - diff --git a/builds/cmake/BuildFunctions.cmake b/builds/cmake/BuildFunctions.cmake index 57fa9c2aca..4d803bd4c1 100644 --- a/builds/cmake/BuildFunctions.cmake +++ b/builds/cmake/BuildFunctions.cmake @@ -12,12 +12,10 @@ function(set_output_directory target dir) if (MSVC OR XCODE) # multiconfiguration builds set(out ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif() - if ("${ARGV2}" STREQUAL "FORCE") - if (MSVC OR XCODE) - set(out ${dir}) - set(dir) - else() - set(out .) + if ("${ARGV2}" STREQUAL "CURRENT_DIR") + set(out .) + if (UNIX AND "${dir}" STREQUAL ".") + set(dir bin) endif() endif() if (MSVC OR XCODE) @@ -98,6 +96,7 @@ function(epp_process type files) OUTPUT ${out} DEPENDS gpre_boot ${in} COMMENT "Calling GPRE boot for ${F}" + # COMMAND ${CMAKE_COMMAND} -E make_directory ${dir} COMMAND ${ARGN} ${in} ${out} ) @@ -106,14 +105,14 @@ function(epp_process type files) set(dir ${dir}/${file}.d) add_custom_command( OUTPUT ${out} - DEPENDS ${in} databases + DEPENDS databases ${in} COMMENT "Calling GPRE master for ${F}" + # COMMAND ${CMAKE_COMMAND} -E make_directory ${dir} COMMAND ${CMAKE_COMMAND} -E copy_if_different metadata.fdb ${dir}/yachts.lnk COMMAND ${CMAKE_COMMAND} -E copy_if_different security.fdb ${dir}/security.fdb COMMAND ${CMAKE_COMMAND} -E copy_if_different msg.fdb ${dir}/msg.fdb COMMAND ${CMAKE_COMMAND} -E copy_if_different help.fdb ${dir}/help.fdb - COMMAND boot_gfix -write async ${dir}/security.fdb COMMAND ${ARGN} -b ${dir}/ ${in} ${out} ) endif() @@ -217,7 +216,7 @@ endfunction(project_group) ####################################### # FUNCTION set_generated_directory ####################################### -function(set_generated_directory) +function(set_generated_directory) if (NOT CMAKE_CROSSCOMPILING) set(GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) else() @@ -229,7 +228,7 @@ endfunction(set_generated_directory) ####################################### # FUNCTION add_dependencies_cc (cross compile) ####################################### -function(add_dependencies_cc target) +function(add_dependencies_cc target) if (NOT CMAKE_CROSSCOMPILING) add_dependencies(${target} ${ARGN}) endif() @@ -238,7 +237,7 @@ endfunction(add_dependencies_cc) ####################################### # FUNCTION add_dependencies_unix_cc (cross compile) ####################################### -function(add_dependencies_unix_cc target) +function(add_dependencies_unix_cc target) if (UNIX) add_dependencies_cc(${target} ${ARGN}) endif() @@ -247,10 +246,21 @@ endfunction(add_dependencies_unix_cc) ####################################### # FUNCTION crosscompile_prebuild_steps ####################################### -function(crosscompile_prebuild_steps) +function(crosscompile_prebuild_steps) if (CMAKE_CROSSCOMPILING) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NATIVE_BUILD_DIR}/src/include/gen/parse.h ${CMAKE_BINARY_DIR}/src/include/gen/parse.h) endif() endfunction(crosscompile_prebuild_steps) +####################################### +# FUNCTION wrap_command_with_path +####################################### +function(wrap_command_with_path command) + set(cmd ${ARGN}) + set_win32(cmd set PATH=%PATH%\\\\;${output_dir} COMMAND ${cmd}) + set_unix (cmd PATH=${output_dir}/bin ${cmd}) + set_apple(cmd DYLD_LIBRARY_PATH=${output_dir}/plugins:${output_dir}/lib ${cmd}) + set(${command} "${cmd}" PARENT_SCOPE) +endfunction(wrap_command_with_path) + ############################################################################### diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3773f95886..9b0849ffb1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -27,7 +27,6 @@ add_custom_command( OUTPUT empbuild.c DEPENDS gpre - messages ${CMAKE_CURRENT_SOURCE_DIR}/empbuild/empbuild.e empbuild.fdb COMMENT "Calling GPRE for empbuild.e" @@ -36,8 +35,8 @@ add_custom_command( add_executable (empbuild empbuild.c empbuild.fdb ${CMAKE_CURRENT_SOURCE_DIR}/empbuild/empbuild.e) target_link_libraries (empbuild yvalve) -set_output_directory (empbuild . FORCE) -add_dependencies_cc (empbuild gfix engine12 fbtrace) +set_output_directory (empbuild . CURRENT_DIR) +add_dependencies_cc (empbuild engine12) project_group (empbuild Examples) file(GLOB files @@ -50,11 +49,12 @@ foreach(F ${files}) COMMAND ${CMAKE_COMMAND} -E copy_if_different ${F} ${name}) endforeach() -set(EMPBUILD_CMD empbuild employe2_.fdb) -set_win32(EMPBUILD_CMD set PATH=%PATH%\\\\;${output_dir} COMMAND ${EMPBUILD_CMD}) -set_unix (EMPBUILD_CMD PATH=${output_dir}/bin ${EMPBUILD_CMD}) -set_apple(EMPBUILD_CMD DYLD_LIBRARY_PATH=${output_dir}/plugins:${output_dir}/lib ${EMPBUILD_CMD}) +######################################## +# BUILD STEP employee_db +######################################## + +wrap_command_with_path(EMPBUILD_CMD $ employe2_.fdb) add_custom_command( OUTPUT employe2.fdb DEPENDS @@ -65,12 +65,12 @@ add_custom_command( COMMAND ${EMPBUILD_CMD} COMMAND ${CMAKE_COMMAND} -E copy_if_different employe2_.fdb employe2.fdb ) -add_custom_target (employee_db DEPENDS employe2.fdb SOURCES ${files}) -add_dependencies_cc (employee_db engine12) -project_group (employee_db Examples) +add_custom_target (employee_db ALL DEPENDS employe2.fdb SOURCES ${files}) +project_group (employee_db "Examples/Custom build steps") endif() # if (NOT CMAKE_CROSSCOMPILING) + ######################################## # SHARED LIBRARY udrcpp_example ######################################## diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc2e056715..6505c9d707 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -171,8 +171,8 @@ add_custom_command( msg_fdb # COMMAND ${CMAKE_COMMAND} -E remove firebird.msg - COMMAND build_msg -D msg.fdb -P ./ -F firebird.msg -L all - COMMAND build_msg -D msg.fdb -P ./ -F firebird.msg + COMMAND build_msg -D msg.fdb -P ${CMAKE_CURRENT_BINARY_DIR}/ -F firebird.msg -L all + COMMAND build_msg -D msg.fdb -P ${CMAKE_CURRENT_BINARY_DIR}/ -F firebird.msg COMMAND ${CMAKE_COMMAND} -E copy_if_different firebird.msg ${output_dir}/firebird.msg ) add_custom_command( @@ -186,7 +186,7 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E echo Building codes header... COMMAND codes ${CMAKE_CURRENT_SOURCE_DIR}/include/gen ${CMAKE_SOURCE_DIR}/lang_helpers ) -add_custom_target(messages DEPENDS firebird.msg codes_headers.dummy) +add_custom_target(messages ALL DEPENDS firebird.msg codes_headers.dummy) project_group(messages "Boot/Custom build steps") @@ -395,7 +395,8 @@ target_link_libraries (boot_yvalve PUBLIC ${LIB_CoreFoundation} ) set_exported_symbols (boot_yvalve firebird) -set_output_directory_unix (boot_yvalve lib) +set_output_directory (boot_yvalve . CURRENT_DIR) +set_output_directory_unix (boot_yvalve lib CURRENT_DIR) project_group (boot_yvalve Boot) endif() # if (NOT CMAKE_CROSSCOMPILING) @@ -474,7 +475,7 @@ if (NOT CMAKE_CROSSCOMPILING) add_library (boot_engine12 SHARED ${engine12_generated_src_boot} ${VERSION_RC}) target_link_libraries (boot_engine12 engine12_common boot_alice boot_burp common boot_yvalve) -set_output_directory (boot_engine12 plugins) +set_output_directory (boot_engine12 plugins CURRENT_DIR) set_exported_symbols (boot_engine12 fbplugin) copy_and_rename_lib (boot_engine12 Engine12) project_group (boot_engine12 Boot) @@ -488,7 +489,6 @@ endif() # if (NOT CMAKE_CROSSCOMPILING) add_library (engine12 SHARED ${engine12_generated_src_master} ${VERSION_RC}) target_link_libraries (engine12 engine12_common alice burp common yvalve) -add_dependencies_cc (engine12 messages) set_target_properties (engine12 PROPERTIES OUTPUT_NAME Engine12) set_output_directory (engine12 plugins) set_exported_symbols (engine12 fbplugin) @@ -502,7 +502,6 @@ file(GLOB intl_src "intl/*.cpp" "intl/*.h") add_library (intl SHARED ${intl_src} ${VERSION_RC}) target_link_libraries (intl common yvalve) -add_dependencies_cc (intl messages) set_target_properties (intl PROPERTIES OUTPUT_NAME fbintl) set_output_directory (intl intl) @@ -618,6 +617,7 @@ if (NOT CMAKE_CROSSCOMPILING) add_executable (gpre_boot ${gpre_boot_src} ${VERSION_RC}) target_link_libraries (gpre_boot gpre_common common ${LIB_Ws2_32}) +set_output_directory (gpre_boot . CURRENT_DIR) project_group (gpre_boot Boot) endif() # if (NOT CMAKE_CROSSCOMPILING) @@ -637,6 +637,7 @@ if (NOT CMAKE_CROSSCOMPILING) add_executable (boot_gpre ${gpre_generated_src_boot} ${VERSION_RC}) target_link_libraries (boot_gpre gpre_common common boot_yvalve) +set_output_directory (boot_gpre . CURRENT_DIR) project_group (boot_gpre Boot) endif() # if (NOT CMAKE_CROSSCOMPILING) @@ -662,7 +663,8 @@ add_epp_suffix(build_msg_generated_src master) if (NOT CMAKE_CROSSCOMPILING) add_executable (build_msg ${build_msg_generated_src_master} ${VERSION_RC}) -target_link_libraries (build_msg common yvalve) +target_link_libraries (build_msg boot_yvalve) +set_output_directory (build_msg . CURRENT_DIR) project_group (build_msg Boot) endif() # if (NOT CMAKE_CROSSCOMPILING) @@ -680,7 +682,8 @@ add_epp_suffix(codes_generated_src master) if (NOT CMAKE_CROSSCOMPILING) add_executable (codes ${codes_generated_src_master} ${VERSION_RC}) -target_link_libraries (codes yvalve) +target_link_libraries (codes boot_yvalve) +set_output_directory (codes . CURRENT_DIR) project_group (codes Boot) endif() # if (NOT CMAKE_CROSSCOMPILING) @@ -703,7 +706,7 @@ add_epp_suffix(gstat_generated_src master) add_executable (gstat ${gstat_src} ${gstat_generated_src_master} ${VERSION_RC}) target_link_libraries (gstat common yvalve) -add_dependencies_cc (gstat engine12 messages) +add_dependencies_cc (gstat engine12) ######################################## @@ -751,10 +754,15 @@ target_link_libraries (fbtracemgr common yvalve) # EXECUTABLE boot_gfix ######################################## +if (NOT CMAKE_CROSSCOMPILING) + add_executable (boot_gfix alice/main/aliceMain.cpp ${VERSION_RC}) target_link_libraries (boot_gfix boot_alice common boot_yvalve) +set_output_directory (boot_gfix . CURRENT_DIR) project_group (boot_gfix Boot) +endif() # if (NOT CMAKE_CROSSCOMPILING) + ######################################## # EXECUTABLE gfix @@ -774,6 +782,7 @@ if (NOT CMAKE_CROSSCOMPILING) add_executable (boot_gbak burp/main/burpMain.cpp ${gbak_include} ${VERSION_RC}) target_link_libraries (boot_gbak boot_burp common boot_yvalve) +set_output_directory (boot_gbak . CURRENT_DIR) project_group (boot_gbak Boot) endif() # if (NOT CMAKE_CROSSCOMPILING) @@ -813,6 +822,7 @@ if (NOT CMAKE_CROSSCOMPILING) add_executable (boot_isql ${isql_src} ${isql_generated_src_boot} ${VERSION_RC}) target_link_libraries (boot_isql common boot_yvalve) +set_output_directory (boot_isql . CURRENT_DIR) project_group (boot_isql Boot) endif() # if (NOT CMAKE_CROSSCOMPILING) @@ -821,11 +831,13 @@ if (WIN32) add_custom_command( TARGET boot_isql POST_BUILD - # remove - COMMAND ${CMAKE_COMMAND} -E remove ${output_dir}/icudt52l.dat ${output_dir}/icudt52l_empty.dat # - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/extern/icu/icudt52l.dat ${output_dir}/icudt52l.dat - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/extern/icu/icudt52l_empty.dat ${output_dir}/icudt52l_empty.dat + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/icudt52l.dat ${output_dir}/icudt52l.dat + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/icudt52l_empty.dat ${output_dir}/icudt52l_empty.dat + # + # one copy to boot directory + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/icudt52l.dat $/icudt52l.dat + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/icudt52l_empty.dat $/icudt52l_empty.dat ) string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "/machine:x64" arch) @@ -838,15 +850,19 @@ if (WIN32) TARGET boot_isql POST_BUILD # icu - # remove - COMMAND ${CMAKE_COMMAND} -E remove ${output_dir}/icudt52.dll ${output_dir}/icuin52.dll ${output_dir}/icuuc52.dll - # - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icudt52.dll ${output_dir}/icudt52.dll - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icuin52.dll ${output_dir}/icuin52.dll - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icuuc52.dll ${output_dir}/icuuc52.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icudt52.dll ${output_dir}/icudt52.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icuin52.dll ${output_dir}/icuin52.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icuuc52.dll ${output_dir}/icuuc52.dll # zlib - COMMAND ${CMAKE_COMMAND} -E remove ${output_dir}/zlib1.dll - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/extern/zlib/${arch}/zlib1.dll ${output_dir}/zlib1.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/zlib/${arch}/zlib1.dll ${output_dir}/zlib1.dll + # + # one copy to boot directory + # icu + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icudt52.dll $/icudt52.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icuin52.dll $/icuin52.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/icu/${arch}/Release/bin/icuuc52.dll $/icuuc52.dll + # zlib + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/extern/zlib/${arch}/zlib1.dll $/zlib1.dll ) endif() @@ -931,7 +947,7 @@ add_custom_target(copy_files COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/src/include/gen/iberror.h ${output_dir}/include/iberror.h COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/src/yvalve/perf.h ${output_dir}/include/perf.h ) -add_dependencies_cc (copy_files databases employee_db) +add_dependencies_cc (copy_files databases) add_dependencies_unix_cc(copy_files makeHeader) project_group(copy_files "Custom build steps") @@ -1020,7 +1036,7 @@ if (UNIX) if (NOT CMAKE_CROSSCOMPILING) add_executable (makeHeader misc/makeHeader.cpp) - set_output_directory (makeHeader . FORCE) + set_output_directory (makeHeader . CURRENT_DIR) set(files ${CMAKE_SOURCE_DIR}/src/include/types_pub.h ${CMAKE_SOURCE_DIR}/src/include/consts_pub.h diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index e7418f1d61..b275a1e7e3 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -57,7 +57,6 @@ file(GLOB fbtrace_include "ntrace/*.h") add_library (fbtrace SHARED ${fbtrace_src} ${fbtrace_os_src} ${fbtrace_include} ${VERSION_RC}) target_link_libraries (fbtrace common yvalve) -add_dependencies_cc (fbtrace engine12 build_msg codes) # try to wait all generators stop set_output_directory (fbtrace plugins) set_exported_symbols (fbtrace fbplugin)