-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1445 from mcallegari/cmakebuild
Add cmake build support
- Loading branch information
Showing
169 changed files
with
9,350 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,6 @@ coverage/ | |
|
||
# Development IDEs | ||
.vscode/ | ||
|
||
# CMake build | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
project(qlcplus VERSION 4.12.8 LANGUAGES C CXX) | ||
|
||
# Set Release build type by default | ||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) | ||
endif() | ||
|
||
# Prevent CMake make install strips off non-standard build paths | ||
# Refer to https://stackoverflow.com/questions/7970544/cmake-make-install-output-cant-find-shared-qt-libraries-under-redhat | ||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
|
||
SET(INSTALL_ROOT "/" CACHE STRING "Installation root directory") | ||
|
||
if(UNIX) | ||
if (APPLE) | ||
set(iokit ON) | ||
else() | ||
set(udev ON) | ||
endif() | ||
endif() | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
# Set up AUTOMOC and some sensible defaults for runtime execution | ||
# When using Qt 6.3, you can replace the code block below with | ||
# qt_standard_project_setup() | ||
set(CMAKE_AUTOMOC ON) | ||
include(GNUInstallDirs) | ||
|
||
find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core) | ||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS 3DCore 3DInput 3DQuick 3DQuickExtras 3DRender Gui Multimedia MultimediaWidgets Network PrintSupport Qml Quick Svg Test Widgets LinguistTools) | ||
|
||
message("Found Qt version ${QT_VERSION_MAJOR}: ${QT_DIR}") | ||
|
||
if(QT_VERSION_MAJOR EQUAL 5) | ||
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Script) | ||
endif() | ||
|
||
find_package(PkgConfig REQUIRED) | ||
|
||
include(./variables.cmake) | ||
include(./coverage.cmake) | ||
|
||
if((((QT_VERSION_MAJOR LESS 5)) AND (APPLE))) | ||
pkg_check_modules(PORTAUDIO_2 IMPORTED_TARGET portaudio-2.0) | ||
endif() | ||
|
||
if(WIN32) | ||
# Prefix all shared libraries with ''. | ||
set(CMAKE_SHARED_LIBRARY_PREFIX "") | ||
endif() | ||
|
||
add_subdirectory(hotplugmonitor) | ||
add_subdirectory(engine) | ||
add_subdirectory(resources) | ||
add_subdirectory(plugins) | ||
if(qmlui) | ||
message("Building QLC+ 5 QML UI") | ||
add_subdirectory(qmlui) | ||
else() | ||
message("Building QLC+ 4 QtWidget UI") | ||
add_subdirectory(ui) | ||
add_subdirectory(webaccess) | ||
add_subdirectory(main) | ||
add_subdirectory(fixtureeditor) | ||
endif() | ||
if(APPLE AND NOT qmlui) | ||
add_subdirectory(launcher) | ||
endif() | ||
|
||
# Unit testing thru "make check" | ||
if(qmlui) | ||
if(WIN32) | ||
add_custom_target(unittests | ||
COMMAND unittest_cmake.bat "qmlui" ${CMAKE_CURRENT_BINARY_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
else() | ||
add_custom_target(unittests | ||
COMMAND ./unittest_cmake.sh "qmlui" ${CMAKE_CURRENT_BINARY_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
endif() | ||
else() | ||
if(WIN32) | ||
add_custom_target(unittests | ||
COMMAND unittest_cmake.bat "ui" ${CMAKE_CURRENT_BINARY_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
else() | ||
add_custom_target(unittests | ||
COMMAND ./unittest_cmake.sh "ui" ${CMAKE_CURRENT_BINARY_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
endif() | ||
endif() | ||
|
||
add_custom_target(check | ||
DEPENDS unittests | ||
) | ||
|
||
# Unit test coverage measurement | ||
if(WIN32) | ||
add_custom_target(coverage | ||
COMMAND @echo Get a better OS. | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
else() | ||
if(qmlui) | ||
add_custom_target(coverage | ||
COMMAND ./coverage_cmake.sh "qmlui" | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
else() | ||
add_custom_target(coverage | ||
COMMAND ./coverage_cmake.sh "ui" | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
endif() | ||
endif() | ||
|
||
add_custom_target(lcov | ||
DEPENDS coverage | ||
) | ||
|
||
# Translations | ||
if (qmlui) | ||
add_custom_target(translations ALL | ||
COMMAND ./translate.sh "qmlui" | ||
COMMENT "Translating qmlui translations..." | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||
else () | ||
add_custom_target(translations ALL | ||
COMMAND ./translate.sh "ui" | ||
COMMENT "Translating ui translations..." | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||
endif() | ||
|
||
## Add the generated qm files to the list | ||
file(GLOB translations_qm_files "${CMAKE_CURRENT_SOURCE_DIR}/*.qm") | ||
|
||
## Install the qm files | ||
if (appimage) | ||
set(translations_install_path "${TARGET_DIR}/${INSTALLROOT}/${TRANSLATIONDIR}") | ||
else () | ||
set(translations_install_path "${INSTALLROOT}/${TRANSLATIONDIR}") | ||
endif() | ||
|
||
install(FILES ${translations_qm_files} DESTINATION ${translations_install_path}) | ||
|
||
## Clean the generated files | ||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.qm") | ||
|
||
# run | ||
if(UNIX) | ||
if(qmlui) | ||
add_custom_target(run | ||
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=engine/src:$ENV{LD_LIBRARY_PATH} qmlui/qlcplus-qml | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
) | ||
else() | ||
add_custom_target(run | ||
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=engine/src:ui/src:webaccess/src:$ENV{LD_LIBRARY_PATH} main/qlcplus | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
) | ||
endif() | ||
endif() | ||
|
||
# run-fxe | ||
if(UNIX AND NOT qmlui) | ||
add_custom_target(run-fxe | ||
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=engine/src:ui/src:webaccess/src:$ENV{LD_LIBRARY_PATH} ./fixtureeditor/qlcplus-fixtureeditor | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
) | ||
endif() | ||
|
||
# doxygen | ||
if(UNIX) | ||
add_custom_target(doxygen | ||
COMMAND cd resources/doxygen && rm -rf html/ && doxygen qlcplus.dox | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
endif() | ||
|
||
# uninstall target | ||
if(NOT TARGET uninstall) | ||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | ||
IMMEDIATE @ONLY) | ||
|
||
add_custom_target(uninstall | ||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) | ||
endif() | ||
|
||
SET(CPACK_GENERATOR "DEB") | ||
set(CPACK_PACKAGE_NAME "qlcplus") | ||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Massimo Callegari") #required | ||
INCLUDE(CPack) | ||
|
||
# Leave this on the last row of this file | ||
add_subdirectory(platforms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") | ||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") | ||
endif() | ||
|
||
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) | ||
string(REGEX REPLACE "\n" ";" files "${files}") | ||
foreach(file ${files}) | ||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}") | ||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") | ||
exec_program( | ||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" | ||
OUTPUT_VARIABLE rm_out | ||
RETURN_VALUE rm_retval | ||
) | ||
if(NOT "${rm_retval}" STREQUAL 0) | ||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") | ||
endif() | ||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") | ||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.") | ||
endif() | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
if(coverage) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") | ||
file(GLOB_RECURSE gcov_files "${CMAKE_BINARY_DIR}/*.gcno" "${CMAKE_BINARY_DIR}/*.gcda") | ||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${gcov_files}) | ||
endif() |
Oops, something went wrong.