Cleaned up the build

This commit is contained in:
Efi Fogel 2024-01-08 17:19:35 +02:00
parent 13b22abd4f
commit a086c3b8a5
2 changed files with 62 additions and 72 deletions

View File

@ -1,3 +1,5 @@
# This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.23)
project(earth LANGUAGES CXX)
@ -10,90 +12,79 @@ if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW)
endif()
# if(NOT DEFINED INSTALL_EXAMPLESDIR)
# set(INSTALL_EXAMPLESDIR "examples")
# endif()
# set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/earth")
# CGAL and its components
find_package(CGAL QUIET COMPONENTS)
if (NOT CGAL_FOUND)
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL OpenGLWidgets Widgets Xml)
add_definitions(-DQT_NO_VERSION_TAGGING)
# Boost and its components
find_package(CGAL COMPONENTS Qt6)
find_package(Boost REQUIRED)
if (NOT Boost_FOUND)
message(STATUS "This project requires the Boost library, and will not be compiled.")
if (NOT CGAL_FOUND OR NOT CGAL_Qt6_FOUND OR NOT Qt6_FOUND OR NOT Boost_FOUND)
if (NOT CGAL_FOUND)
set(MISSING_DEPS "the CGAL library, ${MISSING_DEPS}")
endif()
if (NOT CGAL_Qt6_FOUND)
set(MISSING_DEPS "the CGAL Qt6 component, ${MISSING_DEPS}")
endif()
if (NOT CGAL_Qt6_FOUND)
set(MISSING_DEPS "the Qt6 library, ${MISSING_DEPS}")
endif()
if (NOT CGAL_Boost_FOUND)
set(MISSING_DEPS "the Boost library, ${MISSING_DEPS}")
endif()
message(STATUS "This project requires ${MISSING_DEPS} and will not be compiled.")
return()
endif()
################################################################################
include(FetchContent)
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json
GIT_TAG v3.11.3)
FetchContent_MakeAvailable(json)
# find_package(nlohmann_json 3.2.0 REQUIRED)
################################################################################
add_definitions(-DQT_NO_VERSION_TAGGING)
# AOS
file(GLOB source_files_aos
Aos.h Aos.cpp
Aos_defs.h
Aos_triangulator.h Aos_triangulator.cpp
)
file(GLOB source_files_aos Aos.h Aos.cpp Aos_defs.h
Aos_triangulator.h Aos_triangulator.cpp)
source_group("Aos" FILES ${source_files_aos})
# GIS
file(GLOB source_files_gis
Kml_reader.h Kml_reader.cpp
)
file(GLOB source_files_gis Kml_reader.h Kml_reader.cpp)
source_group("GIS" FILES ${source_files_gis})
# GRAPHICS
file(GLOB source_files_graphics
Camera.h Camera.cpp
Shader_program.h Shader_program.cpp
)
source_group( "Graphics" FILES ${source_files_graphics} )
file(GLOB source_files_graphics Camera.h Camera.cpp
Shader_program.h Shader_program.cpp)
source_group("Graphics" FILES ${source_files_graphics})
# GRAPHICS-GEOMETRY (Graphics-related)
file(GLOB source_files_graphics_geometry
Line_strips.h Line_strips.cpp
Single_vertex.h Single_vertex.cpp
Sphere.h Sphere.cpp
Triangles.h Triangles.cpp
Vertices.h Vertices.cpp
World_coordinate_axes.h World_coordinate_axes.cpp
)
Line_strips.h Line_strips.cpp
Single_vertex.h Single_vertex.cpp
Sphere.h Sphere.cpp
Triangles.h Triangles.cpp
Vertices.h Vertices.cpp
World_coordinate_axes.h World_coordinate_axes.cpp)
source_group("Graphics_Geometry" FILES ${source_files_graphics_geometry})
# GUI
file(GLOB source_files_gui
Camera_manip.h Camera_manip.cpp
Camera_manip_rot.h Camera_manip_rot.cpp
Camera_manip_rot_bpa.h Camera_manip_rot_bpa.cpp
Camera_manip_zoom.h Camera_manip_zoom.cpp
GUI_country_pick_handler.h GUI_country_pick_handler.cpp
GUI_event_handler.h GUI_event_handler.cpp
)
Camera_manip.h Camera_manip.cpp
Camera_manip_rot.h Camera_manip_rot.cpp
Camera_manip_rot_bpa.h Camera_manip_rot_bpa.cpp
Camera_manip_zoom.h Camera_manip_zoom.cpp
GUI_country_pick_handler.h GUI_country_pick_handler.cpp
GUI_event_handler.h GUI_event_handler.cpp)
source_group("GUI" FILES ${source_files_gui})
#SOURCE FILES (NOT CATEGORIZED YET)
file(GLOB source_files
Common_defs.h
main.cpp
Main_widget.h Main_widget.cpp
Message_manager.h Message_manager.cpp
Timer.h
Tools.h Tools.cpp
Verification.h Verification.cpp
)
file(GLOB source_files Common_defs.h earth.cpp Timer.h
Main_widget.h Main_widget.cpp
Message_manager.h Message_manager.cpp
Tools.h Tools.cpp
Verification.h Verification.cpp)
source_group("Source Files" FILES ${source_files})
qt_standard_project_setup()
@ -108,30 +99,29 @@ qt_add_executable(earth
)
set_target_properties(earth PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
if (MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
endif (MSVC)
target_link_libraries(earth PRIVATE
Qt6::Core
Qt6::Gui
Qt6::OpenGL
Qt6::OpenGLWidgets
Qt6::Widgets
Qt6::Xml
CGAL::CGAL
nlohmann_json::nlohmann_json
)
Qt6::Core
Qt6::Gui
Qt6::OpenGL
Qt6::OpenGLWidgets
Qt6::Widgets
Qt6::Xml
CGAL::CGAL
nlohmann_json::nlohmann_json)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/shaders
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
install(TARGETS earth
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)