Skip to content

Commit

Permalink
support cmake build
Browse files Browse the repository at this point in the history
  • Loading branch information
heterophyllus committed Jul 17, 2022
1 parent 6207c81 commit 9ec8f64
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 0 deletions.
134 changes: 134 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
cmake_minimum_required(VERSION 3.5)

project(GlassPlotter)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


# If cmake raises "QT_DIR not found" error, set Qt install path explicitly.
# set(CMAKE_PREFIX_PATH "C:/Qt/(version)/(kit)")
find_package(Qt5 COMPONENTS Core Gui Widgets PrintSupport REQUIRED)


set(GLASSPLOTTER_SOURCES
src/qcustomtablewidget.cpp
src/global_settings_io.cpp
src/air.cpp
src/preference_dialog.cpp
src/catalog_view_form.cpp
src/catalog_view_setting_dialog.cpp
src/curve_fitting_dialog.cpp
src/dispersion_plot_form.cpp
src/dndt_plot_form.cpp
src/glass.cpp
src/glass_catalog.cpp
src/glass_catalog_manager.cpp
src/glass_datasheet_form.cpp
src/glass_selection_dialog.cpp
src/glass_search_form.cpp
src/glassmap_form.cpp
src/load_catalog_result_dialog.cpp
src/main.cpp
src/main_window.cpp
src/preset_dialog.cpp
src/property_plot_form.cpp
src/qcpscatterchart.cpp
src/spectral_line.cpp
src/transmittance_plot_form.cpp
${CMAKE_SOURCE_DIR}/3rdparty/QCustomPlot/qcustomplot.cpp
${CMAKE_SOURCE_DIR}/3rdparty/pugixml/src/pugixml.cpp
)

set(GLASSPLOTTER_HEADERS
src/qcustomtablewidget.h
src/global_settings_io.h
src/air.h
src/preference_dialog.h
src/catalog_view_form.h
src/catalog_view_setting_dialog.h
src/curve_fitting_dialog.h
src/dispersion_formula.h
src/dispersion_plot_form.h
src/dndt_plot_form.h
src/glass.h
src/glass_catalog.h
src/glass_catalog_manager.h
src/glass_datasheet_form.h
src/glass_selection_dialog.h
src/glass_search_form.h
src/glassmap_form.h
src/load_catalog_result_dialog.h
src/main_window.h
src/preset_dialog.h
src/property_plot_form.h
src/qcpscatterchart.h
src/spectral_line.h
src/transmittance_plot_form.h
3rdparty/QCustomPlot/qcustomplot.h
)

set(GLASSPLOTTER_FORMS
src/preference_dialog.ui
src/glassmap_form.ui
src/catalog_view_form.ui
src/catalog_view_setting_dialog.ui
src/curve_fitting_dialog.ui
src/dispersion_plot_form.ui
src/dndt_plot_form.ui
src/glass_datasheet_form.ui
src/glass_selection_dialog.ui
src/glass_search_form.ui
src/load_catalog_result_dialog.ui
src/main_window.ui
src/preset_dialog.ui
src/transmittance_plot_form.ui
)

if(WIN32)
set(APP_ICON_WIN32_RESOURCE "${CMAKE_SOURCE_DIR}/resource.rc")
add_executable(${PROJECT_NAME}
${GLASSPLOTTER_SOURCES}
${GLASSPLOTTER_HEADERS}
${GLASSPLOTTER_FORMS}
${APP_ICON_WIN32_RESOURCE} )

else(APPLE)
# 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 GlassPlotterIcon.icns)

# And the following tells CMake where to find and install the file itself.
set(APP_ICON_MACOS "${CMAKE_SOURCE_DIR}/data/icon/GlassPlotterIcon.icns")
set_source_files_properties(${APP_ICON_MACOS} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
add_executable(${PROJECT_NAME} MACOSX_BUNDLE
${GLASSPLOTTER_SOURCES}
${GLASSPLOTTER_HEADERS}
${GLASSPLOTTER_FORMS}
${APP_ICON_MACOS})
endif(WIN32)

target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_SOURCE_DIR}/3rdparty
${CMAKE_SOURCE_DIR}/3rdparty/QCustomPlot
${CMAKE_SOURCE_DIR}/3rdparty/spline/src
${CMAKE_SOURCE_DIR}/3rdparty/pugixml/src
)

target_link_libraries(${PROJECT_NAME} PUBLIC
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::PrintSupport
)

# surpress console window
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif()
3 changes: 3 additions & 0 deletions resource.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

ID_ICON_1 ICON DISCARDABLE "data/icon/GlassPlotterIcon.ico"

0 comments on commit 9ec8f64

Please sign in to comment.