Files
IfcOpenShell/src/qtviewer/CMakeLists.txt
T
2024-04-16 11:17:07 +02:00

103 lines
3.7 KiB
CMake

################################################################################
# #
# This file is part of IfcOpenShell. #
# #
# IfcOpenShell is free software: you can redistribute it and/or modify #
# it under the terms of the Lesser GNU General Public License as published by #
# the Free Software Foundation, either version 3.0 of the License, or #
# (at your option) any later version. #
# #
# IfcOpenShell is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# Lesser GNU General Public License for more details. #
# #
# You should have received a copy of the Lesser GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
################################################################################
cmake_minimum_required(VERSION 3.1.3)
message("Running CMakeLists.txt in /src/qtviewer")
# Specify the Qt version and components to use
set(QT_VERSION 6 CACHE STRING "Qt version")
set(QT_COMPONENTS Core Gui OpenGL OpenGLWidgets Widgets CACHE STRING "Qt components")
find_package(Qt${QT_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED PATHS ${QT_DIR})
if(Qt${QT_VERSION}_FOUND)
message(STATUS "Found Qt Version: ${Qt${QT_VERSION}_VERSION}")
endif()
message(STATUS "OSG_DIR: ${OSG_DIR}")
set(OSG_COMPONENTS osgDB osgGA osgUtil osgViewer CACHE STRING "OSG components")
# Do not add "PATHS <path>" in find_package for OpenSceneGraph CMake config to work
# on appleSiliconMacOS + Homebrew
find_package(OpenSceneGraph COMPONENTS ${OSG_COMPONENTS} REQUIRED)
if(OPENSCENEGRAPH_FOUND)
message(STATUS "Found OpenSceneGraph Version: ${OPENSCENEGRAPH_VERSION}")
endif()
set(targetName "QtViewer")
# Scan for .qrc files and add to build process
set(CMAKE_AUTORCC ON)
set(RESOURCE_FILES
resources/qt_resources.qrc
resources/qt_res.rc
)
# The MACOSX_BUNDLE_ICON_FILE variable is added to the Info.plist
# generated by CMake. This variable contains the .icns file name,
# without the path.
set(MACOSX_BUNDLE_ICON_FILE ifcosLogo.icns)
# The following tells CMake where to find and install the file itself.
set(app_icon_macos "resources/ifcosLogo.icns")
set_source_files_properties(${app_icon_macos} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
add_executable(${targetName}
MessageLogger.h
IfcViewerWidget.h
IfcViewerWidget.cpp
ParseIfcFile.h
ParseIfcFile.cpp
MainWindow.h
MainWindow.cpp
main.cpp
${RESOURCE_FILES}
${app_icon_macos}
)
set_target_properties(${targetName} PROPERTIES
AUTOMOC On
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
RESOURCE "${RESOURCE_FILES}"
)
target_link_libraries(${targetName}
${IFCOPENSHELL_LIBRARIES}
${OPENCASCADE_LIBRARIES}
${OPENSCENEGRAPH_LIBRARIES}
Qt${QT_VERSION}::Core
Qt${QT_VERSION}::Gui
Qt${QT_VERSION}::OpenGL
Qt${QT_VERSION}::OpenGLWidgets
Qt${QT_VERSION}::Widgets
)
target_include_directories(${targetName} PUBLIC
${QT_DIR}/include
${OPENSCENEGRAPH_INCLUDE_DIRS}
)
get_target_property(targetIncludeDirs ${targetName} INCLUDE_DIRECTORIES)
message(STATUS "target_include_directories: ${targetIncludeDirs}")