Warning, /education/gcompris/cmake/box2d.cmake is written in an unsupported language. File is not indexed.
0001 #============================================================================= 0002 # SPDX-FileCopyrightText: 2018 Johnny Jazeix <jazeix@gmail.com> 0003 # 0004 # SPDX-License-Identifier: BSD-3-Clause 0005 #============================================================================= 0006 0007 set(QML_BOX2D_MODULE "auto" CACHE STRING "Policy for qml-box2d module [auto|submodule|system|disabled]") 0008 0009 if(NOT ${QML_BOX2D_MODULE} STREQUAL "disabled") 0010 include(qt_helper) 0011 0012 getQtQmlPath(_qt_qml_system_path) 0013 set(_box2d_system_dir "${_qt_qml_system_path}/Box2D.2.0") 0014 0015 if(${QML_BOX2D_MODULE} STREQUAL "submodule") 0016 message(STATUS "Building qml-box2d module from submodule") 0017 set(_need_box2d_submodule "TRUE") 0018 else() 0019 # try to find module in system scope 0020 find_library(QML_BOX2D_LIBRARY NAMES Box2D libBox2D PATHS ${_box2d_system_dir} NO_DEFAULT_PATH) 0021 # Look in default path if not found 0022 if(NOT QML_BOX2D_LIBRARY AND NOT "${CMAKE_FIND_ROOT_PATH}" STREQUAL "") 0023 # Remove the root path to look for the library 0024 set(_box2d_without_cmake_find_root_path) 0025 string(REPLACE "${CMAKE_FIND_ROOT_PATH}" "" _box2d_without_cmake_find_root_path ${_box2d_system_dir}) 0026 find_library(QML_BOX2D_LIBRARY NAMES Box2D libBox2D PATHS ${_box2d_without_cmake_find_root_path}) 0027 endif() 0028 0029 if(QML_BOX2D_LIBRARY) 0030 message(STATUS "Using system qml-box2d plugin at ${QML_BOX2D_LIBRARY}") 0031 # for packaging builds, copy the module manually to the correct location 0032 if(SAILFISHOS) 0033 file(COPY ${_box2d_system_dir}/qmldir ${QML_BOX2D_LIBRARY} DESTINATION share/harbour-gcompris-qt/lib/qml/Box2D.2.0) 0034 elseif(ANDROID) 0035 file(COPY ${_box2d_system_dir}/qmldir ${QML_BOX2D_LIBRARY} DESTINATION lib/qml/Box2D.2.0) 0036 endif() 0037 # FIXME: add others as needed 0038 else() 0039 if(${QML_BOX2D_MODULE} STREQUAL "auto") 0040 message(STATUS "Did not find the qml-box2d module in system scope, falling back to submodule build ...") 0041 set(_need_box2d_submodule "TRUE") 0042 else() 0043 message(FATAL_ERROR "Did not find the qml-box2d module in system scope and submodule build was not requested. Can't continue!") 0044 endif() 0045 endif() 0046 endif() 0047 0048 if(_need_box2d_submodule) 0049 # build qml-box2d ourselves from submodule 0050 include(ExternalProject) 0051 if(UBUNTU_TOUCH) 0052 unset(QT_QMAKE_EXECUTABLE CACHE) 0053 find_program(_qmake_program "qmake") 0054 #set(_qmake_program ${QT_QMAKE_EXECUTABLE}) 0055 else() 0056 get_property(_qmake_program TARGET Qt5::qmake PROPERTY IMPORT_LOCATION) 0057 endif() 0058 set(_box2d_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/external/qml-box2d) 0059 if(WIN32) 0060 set(_box2d_library_dir "release/") 0061 set(_box2d_library_file "Box2D.dll") 0062 elseif(CMAKE_HOST_APPLE) 0063 set(_box2d_library_dir "") 0064 set(_box2d_library_file "libBox2D.dylib") 0065 else() 0066 set(_box2d_library_dir "") 0067 set(_box2d_library_file "libBox2D.so") 0068 endif() 0069 set(_box2d_install_dir ${CMAKE_CURRENT_BINARY_DIR}/lib/qml/Box2D.2.0) 0070 # make sure submodule is up2date 0071 find_package(Git) 0072 if(GIT_FOUND) 0073 execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) 0074 endif() 0075 0076 # for visual studio, we need to create a vcxproj 0077 if(WIN32 AND NOT MINGW) 0078 set(_qmake_options -spec win32-msvc -tp vc) 0079 else() 0080 set(_qmake_options "") 0081 endif() 0082 set(BOX2D_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM}) 0083 # Ninja is not supported by qmake. 0084 # In case Ninja is set as generator, use make on Linux, nmake on Windows 0085 if(${CMAKE_GENERATOR} MATCHES "Ninja") 0086 if(WIN32) 0087 set(QMAKE_MAKE_PROGRAM "nmake") 0088 else() 0089 set(QMAKE_MAKE_PROGRAM "make") 0090 endif() 0091 endif() 0092 ExternalProject_Add(qml_box2d 0093 DOWNLOAD_COMMAND "" 0094 SOURCE_DIR ${_box2d_source_dir} 0095 CONFIGURE_COMMAND ${_qmake_program} ${_qmake_options} ${_box2d_source_dir}/box2d.pro 0096 BUILD_COMMAND ${QMAKE_MAKE_PROGRAM} 0097 INSTALL_DIR ${_box2d_install_dir} 0098 INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${_box2d_library_dir}${_box2d_library_file} ${_box2d_source_dir}/qmldir ${_box2d_install_dir} 0099 ) 0100 0101 add_library(qml-box2d SHARED IMPORTED) 0102 set_target_properties(qml-box2d PROPERTIES IMPORTED_LOCATION ${_box2d_install_dir}/${_box2d_library_file}) 0103 0104 if(SAILFISHOS) 0105 install(DIRECTORY ${_box2d_install_dir} DESTINATION share/harbour-gcompris-qt/lib/qml) 0106 elseif(APPLE) 0107 install(DIRECTORY ${_box2d_install_dir} DESTINATION gcompris-qt.app/Contents/lib/qml) 0108 else() 0109 install(DIRECTORY ${_box2d_install_dir} DESTINATION lib/qml) 0110 endif() 0111 endif() 0112 endif()