1 #### Fast .stl viewer #####
2 # Original Project Author: Matt Keeter Copyright 2014 -2017
3 # Author: Paul Tsouchlos Copyright 2017
5 cmake_minimum_required(VERSION 3.3)
10 set(CMAKE_CXX_STANDARD 11)
11 # Setting standard to required, as requisted by DeveloperPaul123 on github
12 set(CXX_STANDARD_REQUIRED ON)
14 # Set the version number
15 set (FSTL_VERSION_MAJOR "0")
16 set (FSTL_VERSION_MINOR "10")
17 set (FSTL_VERSION_PATCH "0")
18 set (PROJECT_VERSION "${FSTL_VERSION_MAJOR}.${FSTL_VERSION_MINOR}.${FSTL_VERSION_PATCH}")
20 message(STATUS "Version: ${PROJECT_VERSION}")
23 set(CMAKE_INCLUDE_CURRENT_DIR ON)
27 set(Project_Sources src/app.cpp
38 set(Project_Headers src/app.h
47 #set project resources and icon resource
48 set(Project_Resources qt/qt.qrc gl/gl.qrc)
49 set(Icon_Resource exe/fstl.rc)
51 #set Policy CMP0072 FindOpenGL behavior
52 set(OpenGL_GL_PREFERENCE GLVND)
54 #find required packages.
55 find_package(Qt5 5.14 REQUIRED COMPONENTS Core Gui Widgets OpenGL)
56 find_package(OpenGL REQUIRED)
57 find_package(Threads REQUIRED)
60 qt5_add_resources(Project_Resources_RCC ${Project_Resources})
62 #tell CMake AUTOGEN to skip autogen on the generated qrc files
63 set_property(SOURCE ${Project_Resources_RCC} PROPERTY SKIP_AUTOGEN ON)
65 #include opengl files.
66 include_directories(${QT_QTOPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} )
69 add_executable(fstl WIN32 ${Project_Sources} ${Project_Headers} ${Project_Resources_RCC} ${Icon_Resource})
70 set(Fstl_LINK_FLAGS ${CMAKE_CURRENT_SOURCE_DIR}/${Icon_Resource})
71 set_target_properties(fstl PROPERTIES LINK_FLAGS ${Fstl_LINK_FLAGS})
73 add_executable(fstl MACOSX_BUNDLE ${Project_Sources} ${Project_Headers} ${Project_Resources_RCC} ${Icon_Resource})
75 add_executable(fstl ${Project_Sources} ${Project_Headers} ${Project_Resources_RCC} ${Icon_Resource})
78 target_link_libraries(fstl Qt5::Widgets Qt5::Core Qt5::Gui Qt5::OpenGL ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
80 # Add version definitions to use within the code.
81 target_compile_definitions(fstl PRIVATE -DFSTL_VERSION="${PROJECT_VERSION}")
83 #installer information that is platform independent
84 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Fast .stl file viewer.")
85 set(CPACK_PACKAGE_VERSION_MAJOR ${FSTL_VERSION_MAJOR})
86 set(CPACK_PACKAGE_VERSION_MINOR ${FSTL_VERSION_MINOR})
87 set(CPACK_PACKAGE_VERSION_PATCH ${FSTL_VERSION_PATCH})
91 set(QT_USE_QTMAIN true)
94 set_source_files_properties(fstl PROPERTIES LINKER_LANGUAGE "CXX")
95 set_target_properties(fstl PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
97 install(TARGETS fstl DESTINATION bin COMPONENT all)
100 $<TARGET_FILE:Qt5::Gui_EGL>
101 $<TARGET_FILE:Qt5::Gui_GLESv2>
102 $<TARGET_FILE:Qt5::Core>
103 $<TARGET_FILE:Qt5::Gui>
104 $<TARGET_FILE:Qt5::OpenGL>
105 $<TARGET_FILE:Qt5::Widgets>
106 DESTINATION bin COMPONENT all)
108 #install file in the platforms directory.
110 ${Qt5Core_DIR}/../../../plugins/platforms/qwindows.dll
111 DESTINATION bin/platforms COMPONENT all
114 #custom commands based on: https://gist.github.com/Rod-Persky/e6b93e9ee31f9516261b
115 add_custom_command(TARGET fstl POST_BUILD
116 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:${PROJECT_NAME}>
117 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:${PROJECT_NAME}>
118 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:${PROJECT_NAME}>
119 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::OpenGL> $<TARGET_FILE_DIR:${PROJECT_NAME}>
123 # windows specific installer generation information
124 set(CPACK_GENERATOR NSIS)
125 set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL OFF)
126 set(CPACK_NSIS_MODIFY_PATH ON)
127 set(CPACK_NSIS_MUI_FINISHPAGE_RUN ${PROJECT_NAME})
128 set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}")
129 set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\fstl.exe")
130 set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/fstl-app/fstl")
131 set(CPACK_NSIS_DISPLAY_NAME "fstl ${FSTL_VERSION}")
132 set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/exe/fstl.ico")
133 set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/exe/fstl.ico")
134 set(CPACK_NSIS_CREATE_ICONS_EXTRA
135 "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\fstl.lnk' '$INSTDIR\\\\bin\\\\fstl.exe'")
136 set(CPACK_COMPONENTS_ALL all)
138 set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
140 set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
143 set(CPACK_GENERATOR "DragNDrop")
144 set(CPACK_DMG_FORMAT "UDBZ")
145 set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
146 set(CPACK_SYSTEM_NAME "OSX")
147 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
148 set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/app/fstl.icns")
150 install(TARGETS fstl RUNTIME DESTINATION bin)
152 set(CPACK_GENERATOR "DEB;RPM")
153 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")