Sun, 26 Jun 2022 20:26:09 +0300
Fix bad use of QOpenGLFunctions
project(ldforge) cmake_minimum_required(VERSION 2.8.12) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") set(OpenGL_GL_PREFERENCE GLVND) find_package(Qt6 COMPONENTS Core Widgets OpenGL UiPlugin OpenGLWidgets) if (Qt6_FOUND) message(NOTICE "-- Using Qt6") find_package(Qt6 REQUIRED COMPONENTS Core5Compat) # Unfortunately "Qt::UiPlugin" doesn't seem to work so let's resolve # it here instead... add_library(QtUiPlugin ALIAS Qt6::UiPlugin) else() message(NOTICE "-- Qt6 not found, using Qt5 instead") find_package(Qt5 5.5 REQUIRED COMPONENTS Core Widgets OpenGL UiPlugin) add_library(QtUiPlugin ALIAS Qt5::UiPlugin) endif() find_package(OpenGL REQUIRED) find_package(GLM REQUIRED) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${GLM_INCLUDE_DIR}) add_definitions(-DQT_NO_KEYWORDS) source_group("LDForge" REGULAR_EXPRESSION "src/.+\\.(cpp|h|ui)") add_subdirectory(widgets) set (LDFORGE_SOURCES src/colors.cpp src/document.cpp src/documentmanager.cpp src/geometry.cpp src/ldrawalgorithm.cpp src/libraries.cpp src/invert.cpp src/main.cpp src/messagelog.cpp src/model.cpp src/parser.cpp src/polygoncache.cpp src/uiutilities.cpp src/version.cpp src/vertexmap.cpp src/gl/axesprogram.cpp src/gl/basicshaderprogram.cpp src/gl/compiler.cpp src/gl/debug.cpp src/gl/gridprogram.cpp src/gl/partrenderer.cpp # src/gl/vertexprogram.cpp src/settingseditor/keyboardshortcutseditor.cpp src/settingseditor/librarieseditor.cpp src/settingseditor/settingseditor.cpp src/types/boundingbox.cpp src/ui/circletooloptionswidget.cpp src/ui/objecteditor.cpp src/widgets/colorindexinput.cpp src/widgets/colorselectdialog.cpp ) set (LDFORGE_HEADERS src/basics.h src/circularprimitive.h src/colors.h src/document.h src/documentmanager.h src/functional.h src/geometry.h src/invert.h src/ldrawalgorithm.h src/libraries.h src/messagelog.h src/model.h src/parser.h src/polygoncache.h src/ring.h src/settings.h src/typeconversions.h src/uiutilities.h src/version.h src/vertexmap.h src/algorithm/earcut.h src/gl/axesprogram.h src/gl/basicshaderprogram.h src/gl/common.h src/gl/compiler.h src/gl/debug.h src/gl/gridprogram.h src/gl/partrenderer.h # src/gl/vertexprogram.h src/settingseditor/keyboardshortcutseditor.h src/settingseditor/librarieseditor.h src/settingseditor/settingseditor.h src/types/boundingbox.h src/ui/circletooloptionswidget.h src/ui/objecteditor.h src/widgets/colorindexinput.h src/widgets/colorselectdialog.h ) set (LDFORGE_FORMS src/mainwindow.ui src/settingseditor/librarieseditor.ui src/settingseditor/settingseditor.ui src/ui/circletool.ui src/ui/objecteditor.ui src/widgets/colorselectdialog.ui src/widgets/colorindexinput.ui ) set(LDFORGE_LOCALES locale/fi.ts locale/sv.ts ) set (LDFORGE_OTHER_FILES ) set(CMAKE_AUTOUIC_SEARCH_PATHS src/ui) set(LDFORGE_RESOURCES ldforge.qrc) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) include_directories("${PROJECT_BINARY_DIR}") include_directories("${PROJECT_BINARY_DIR}/src") include_directories("${PROJECT_SOURCE_DIR}") include_directories("${PROJECT_SOURCE_DIR}/src") add_custom_target(resources ALL DEPENDS ${LDFORGE_RESOURCES}) if (NOT MSVC) if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wunused") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-fallthrough") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-noexcept-type") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat-nonliteral -Wnonnull -Wnull-dereference -Winfinite-recursion -Wuninitialized -Wmissing-noreturn") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wundef -Wmissing-field-initializers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual -Wcast-align -Wcast-function-type -Wconversion") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-declarations -Wdate-time") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcovered-switch-default -Wextra-semi -Wgnu -Wmicrosoft") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wsometimes-uninitialized -Wstring-concatenation -Wstring-conversion -Wsuggest-override") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override -Wundefined-func-template -Wundefined-reinterpret-cast") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized-const-reference -Wunreachable-code -Wunreachable-code-break -Wunreachable-code-return") endif() qt_add_resources(LDFORGE_QRC ${LDFORGE_RESOURCES}) qt_wrap_ui(LDFORGE_FORMS_HEADERS ${LDFORGE_FORMS}) add_executable(ldforge WIN32 ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} ${LDFORGE_RESOURCES} ${LDFORGE_QRC} ${LDFORGE_FORMS_HEADERS} ${LDFORGE_OTHER_FILES} ) set_source_files_properties(${LDFORGE_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${LDFORGE_RESOURCES} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${LDFORGE_OTHER_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) set_target_properties(ldforge PROPERTIES AUTOMOC 1) target_link_libraries(ldforge PRIVATE Qt::Core) target_link_libraries(ldforge PRIVATE Qt::Widgets) target_link_libraries(ldforge PRIVATE Qt::OpenGL) target_link_libraries(ldforge PRIVATE ${OPENGL_LIBRARIES}) target_link_libraries(ldforge PRIVATE ${GLEW_LIBRARIES}) target_link_libraries(ldforge PRIVATE ldforgewidgets) add_dependencies(ldforge resources) if (Qt6_FOUND) target_link_libraries(ldforge PRIVATE Qt6::Core5Compat) target_link_libraries(ldforge PRIVATE Qt6::OpenGLWidgets) endif() add_custom_target(linelength ALL COMMAND python3 "${CMAKE_SOURCE_DIR}/tools/linelength.py" ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) add_dependencies(ldforge linelength) # Collect the current hg revision into hginfo.h add_custom_target(revision_check ALL COMMAND python3 "${CMAKE_SOURCE_DIR}/tools/updaterevision.py" --cwd "$(CMAKE_SOURCE_DIR)" hginfo.h WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_dependencies(ldforge revision_check) install(TARGETS ldforge RUNTIME DESTINATION bin)