diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a180981e9795449e06d965a90e74fd2cc0daa25..f60472bb13e0d617c286165fcf1f939a2304a32a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,12 +23,6 @@ stages: paths: - build expire_in: 1 day - before_script: - - 'curl -o artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://git.imp.fu-berlin.de/api/v4/projects/2576/jobs/artifacts/master/download?job=package%20ubuntu-18.04"' - - 7z e artifacts.zip; 7z e '*.tar.xz'; rm *.tar.xz; 7z x '*.tar'; rm *.tar - - mkdir dependencies - - name='RF_Interfaces'; mv $name-* dependencies/$name - - export CMAKE_PREFIX_PATH="$(pwd)/dependencies" .build windows: &build_windows stage: build @@ -38,11 +32,6 @@ stages: - build expire_in: 1 day before_script: - - 'curl.exe -o artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://git.imp.fu-berlin.de/api/v4/projects/2576/jobs/artifacts/master/download?job=package%20windows"' - - 7z e artifacts.zip; 7z e *.tar.xz; Remove-Item -Force *.tar.xz; 7z x *.tar; Remove-Item -Force *.tar - - New-Item -ItemType Directory -Force 'dependencies' - - $name='RF_Interfaces'; Move-Item -Force "$name-*" dependencies/$name - - $env:CMAKE_PREFIX_PATH="$((Get-Item -Path '.').FullName)/dependencies;$env:VCPKG_CUDA_INSTALL_DIR" - C:/VsDevEnv.ps1 -arch=amd64 build ubuntu-18.04: @@ -70,12 +59,6 @@ package ubuntu-18.04: <<: *base_ubuntu_18_04 dependencies: - build ubuntu-18.04 - before_script: - - 'curl -o artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://git.imp.fu-berlin.de/api/v4/projects/2576/jobs/artifacts/master/download?job=package%20ubuntu-18.04"' - - 7z e artifacts.zip; 7z e '*.tar.xz'; rm *.tar.xz; 7z x '*.tar'; rm *.tar - - mkdir dependencies - - name='RF_Interfaces'; mv $name-* dependencies/$name - - export CMAKE_PREFIX_PATH="$(pwd)/dependencies" <<: *package package windows: @@ -83,11 +66,6 @@ package windows: dependencies: - build windows before_script: - - 'curl.exe -o artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://git.imp.fu-berlin.de/api/v4/projects/2576/jobs/artifacts/master/download?job=package%20windows%5bcuda%5d"' - - 7z e artifacts.zip; 7z e *.tar.xz; Remove-Item -Force *.tar.xz; 7z x *.tar; Remove-Item -Force *.tar - - New-Item -ItemType Directory -Force 'dependencies' - - $name='RF_Interfaces'; Move-Item -Force "$name-*" dependencies/$name - - $env:CMAKE_PREFIX_PATH="$((Get-Item -Path '.').FullName)/dependencies;$env:VCPKG_CUDA_INSTALL_DIR" - C:/VsDevEnv.ps1 -arch=amd64 <<: *package diff --git a/SrcBehaviorLoader/CMakeLists.txt b/SrcBehaviorLoader/CMakeLists.txt index 52ac3d090accd7a5035ad9243076092c5645a58b..450bdbd6b59346b576a1def4cb5cf59da29ef328 100644 --- a/SrcBehaviorLoader/CMakeLists.txt +++ b/SrcBehaviorLoader/CMakeLists.txt @@ -4,8 +4,8 @@ target_include_directories(${TN} PUBLIC $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}> ) -find_package(RF_Interfaces 0.1 REQUIRED) -target_link_libraries(${TN} RF_Interfaces) +find_package(Qt5 REQUIRED COMPONENTS Core) +target_link_libraries(${TN} Qt5::Core) set_target_properties(${TN} PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(${TN} PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON) diff --git a/cmake/Deploy.cmake b/cmake/Deploy.cmake new file mode 100644 index 0000000000000000000000000000000000000000..80b144e74021a65838adbc9917526959609a9ff2 --- /dev/null +++ b/cmake/Deploy.cmake @@ -0,0 +1,87 @@ +if(WIN32) + function(deploy_shared_lib target directory lib) + set(options TO_BUILD) + cmake_parse_arguments(DEPLOY_SHARED_LIB "${options}" "" "" ${ARGN}) + + message("Searching for ${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}") + execute_process( + COMMAND where.exe "${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}" + OUTPUT_VARIABLE _matches + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _res + ) + if(NOT "${_res}" STREQUAL "0") + message(FATAL_ERROR "Failed to find ${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + string(REGEX REPLACE "\n" ";" _matches "${_matches}") + list(GET _matches 0 _lib) + string(REGEX REPLACE "\\\\" "/" _lib "${_lib}") + + if(DEPLOY_SHARED_LIB_TO_BUILD) + # Deploy into build tree + add_custom_command(TARGET ${target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E + copy_if_different "${_lib}" \"$<TARGET_FILE_DIR:${target}>\" + COMMENT "Copying ${_lib} to \"$<TARGET_FILE_DIR:${target}>\"" + ) + endif() + + # Deploy into install tree + install(CODE + " + if(\"${directory}\" STREQUAL \"\") + set(_dest \"\${CMAKE_INSTALL_PREFIX}\") + else() + set(_dest \"\${CMAKE_INSTALL_PREFIX}/${directory}\") + endif() + message(\"Copying ${_lib} to \${_dest}\") + execute_process( + COMMAND \"${CMAKE_COMMAND}\" -E + copy \"${_lib}\" \"\${_dest}/\" + ) + " + ) + endfunction() + + include(${CMAKE_CURRENT_LIST_DIR}/Windeployqt.cmake) + + function(deploy_qt5 target directory) + windeployqt(${target} "${directory}") + endfunction() + + function(deploy_cuda target directory) + set(multiValueArgs COMPONENTS) + cmake_parse_arguments(DEPLOY_CUDA "" "" "${multiValueArgs}" ${ARGN}) + + if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(CUDA_SUFFIX "64_${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}") + else() + set(CUDA_SUFFIX "32_${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}") + endif() + + foreach(component ${DEPLOY_CUDA_COMPONENTS}) + deploy_shared_lib(${target} "${directory}" "${component}${CUDA_SUFFIX}") + endforeach() + endfunction() + + function(deploy_cudnn target directory version) + if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(CUDNN_SUFFIX "64_${version}") + else() + set(CUDNN_SUFFIX "32_${version}") + endif() + + deploy_shared_lib(${target} "${directory}" "cudnn${CUDNN_SUFFIX}") + endfunction() + + function(deploy_opencv target directory) + set(multiValueArgs COMPONENTS) + cmake_parse_arguments(DEPLOY_OPENCV "" "" "${multiValueArgs}" ${ARGN}) + + set(CV_SUFFIX "${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}") + + foreach(component ${DEPLOY_OPENCV_COMPONENTS}) + deploy_shared_lib(${target} "${directory}" "opencv_${component}${CV_SUFFIX}") + endforeach() + endfunction() +endif() \ No newline at end of file diff --git a/cmake/Windeployqt.cmake b/cmake/Windeployqt.cmake new file mode 100644 index 0000000000000000000000000000000000000000..dae5bbcb7c6551d230b9b47ee005e132a04a8c8a --- /dev/null +++ b/cmake/Windeployqt.cmake @@ -0,0 +1,112 @@ +# The MIT License (MIT) +# +# Copyright (c) 2017 Nathan Osman +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +find_package(Qt5Core REQUIRED) + +# Retrieve the absolute path to qmake and then use that path to find +# the windeployqt binary +get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION) +get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) +find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}") + +# Running this with MSVC 2015 requires CMake 3.6+ +if((MSVC_VERSION VERSION_EQUAL 1900 OR MSVC_VERSION VERSION_GREATER 1900) + AND CMAKE_VERSION VERSION_LESS "3.6") + message(WARNING "Deploying with MSVC 2015+ requires CMake 3.6+") +endif() + +# Add commands that copy the Qt runtime to the target's output directory after +# build and install the Qt runtime to the specified directory +function(windeployqt target directory) + + # Run windeployqt immediately after build + add_custom_command(TARGET ${target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E + env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}" + --verbose 0 + --no-compiler-runtime + --no-angle + --no-opengl-sw + \"$<TARGET_FILE:${target}>\" + ) + + # install(CODE ...) doesn't support generator expressions, but + # file(GENERATE ...) does - store the path in a file + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}_path" + CONTENT "$<TARGET_FILE:${target}>" + ) + + # Before installation, run a series of commands that copy each of the Qt + # runtime files to the appropriate directory for installation + install(CODE + " + file(READ \"${CMAKE_CURRENT_BINARY_DIR}/${target}_path\" _file) + execute_process( + COMMAND \"${CMAKE_COMMAND}\" -E + env PATH=\"${_qt_bin_dir}\" \"${WINDEPLOYQT_EXECUTABLE}\" + --dry-run + --no-compiler-runtime + --no-angle + --no-opengl-sw + --list mapping + \${_file} + OUTPUT_VARIABLE _output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + separate_arguments(_files WINDOWS_COMMAND \${_output}) + while(_files) + list(GET _files 0 _src) + list(GET _files 1 _dest) + if(\"${directory}\" STREQUAL \"\") + set(_dest \"\${CMAKE_INSTALL_PREFIX}/\${_dest}\") + else() + set(_dest \"\${CMAKE_INSTALL_PREFIX}/${directory}/\${_dest}\") + endif() + message(\"Copying \${_src} to \${_dest}\") + execute_process( + COMMAND \"${CMAKE_COMMAND}\" -E + copy \${_src} \"\${_dest}\" + ) + list(REMOVE_AT _files 0 1) + endwhile() + " + ) + + # windeployqt doesn't work correctly with the system runtime libraries, + # so we fall back to one of CMake's own modules for copying them over + set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE) + if("${directory}" STREQUAL "") + set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .) + else() + set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${directory}") + endif() + include(InstallRequiredSystemLibraries) + foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E + copy_if_different "${lib}" \"$<TARGET_FILE_DIR:${target}>\" + ) + endforeach() + +endfunction() + +mark_as_advanced(WINDEPLOYQT_EXECUTABLE)