mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Build: Fix install targets, add SLIC3R_FHS, check resource dir on GUI_App init
Fix #1515
This commit is contained in:
		
							parent
							
								
									02e1636831
								
							
						
					
					
						commit
						8bc8dfaba4
					
				
					 5 changed files with 45 additions and 7 deletions
				
			
		|  | @ -2,6 +2,8 @@ project(Slic3r) | |||
| cmake_minimum_required(VERSION 3.2) | ||||
| 
 | ||||
| include("version.inc") | ||||
| include(GNUInstallDirs) | ||||
| 
 | ||||
| set(SLIC3R_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") | ||||
| file(TO_NATIVE_PATH "${SLIC3R_RESOURCES_DIR}" SLIC3R_RESOURCES_DIR_WIN) | ||||
| 
 | ||||
|  | @ -22,6 +24,7 @@ endif() | |||
| 
 | ||||
| option(SLIC3R_STATIC 			"Compile Slic3r with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL}) | ||||
| option(SLIC3R_GUI    			"Compile Slic3r with GUI components (OpenGL, wxWidgets)" 1) | ||||
| option(SLIC3R_FHS               "Assume Slic3r is to be installed in a FHS directory structure" 0) | ||||
| option(SLIC3R_PROFILE 			"Compile Slic3r with an invasive Shiny profiler" 0) | ||||
| option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1) | ||||
| option(SLIC3R_MSVC_PDB          "Generate PDB files on MSVC in Release mode" 1) | ||||
|  | @ -61,6 +64,8 @@ foreach (DIR ${PREFIX_PATH_CHECK}) | |||
|     endif () | ||||
| endforeach () | ||||
| 
 | ||||
| message(STATUS "SLIC3R_FHS: ${SLIC3R_FHS}") | ||||
| 
 | ||||
| # Add our own cmake module path. | ||||
| list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) | ||||
| 
 | ||||
|  | @ -146,12 +151,14 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STRE | |||
| endif() | ||||
| 
 | ||||
| # Where all the bundled libraries reside? | ||||
| set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/src/) | ||||
| set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/src) | ||||
| set(LIBDIR_BIN ${CMAKE_CURRENT_BINARY_DIR}/src) | ||||
| # For the bundled boost libraries (boost::nowide) | ||||
| include_directories(${LIBDIR}) | ||||
| # For generated header files | ||||
| include_directories(${LIBDIR_BIN}/platform) | ||||
| # For libslic3r.h | ||||
| include_directories(${LIBDIR}/clipper ${LIBDIR}/polypartition) | ||||
| #set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||||
| 
 | ||||
| if(WIN32) | ||||
|     # BOOST_ALL_NO_LIB: Avoid the automatic linking of Boost libraries on Windows. Rather rely on explicit linking. | ||||
|  | @ -215,7 +222,6 @@ endif() | |||
| # The Intel TBB library will use the std::exception_ptr feature of C++11. | ||||
| add_definitions(-DTBB_USE_CAPTURED_EXCEPTION=0) | ||||
| 
 | ||||
| #set(CURL_DEBUG 1) | ||||
| find_package(CURL REQUIRED) | ||||
| include_directories(${CURL_INCLUDE_DIRS}) | ||||
| 
 | ||||
|  | @ -280,7 +286,6 @@ include_directories(${GLEW_INCLUDE_DIRS}) | |||
| # l10n | ||||
| set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization") | ||||
| add_custom_target(pot | ||||
|     # FIXME: file list stale | ||||
|     COMMAND xgettext --keyword=L --from-code=UTF-8 --debug | ||||
|         -f "${L10N_DIR}/list.txt" | ||||
|         -o "${L10N_DIR}/Slic3rPE.pot" | ||||
|  | @ -307,5 +312,12 @@ if(SLIC3R_BUILD_TESTS) | |||
|     add_subdirectory(tests) | ||||
| endif() | ||||
| 
 | ||||
| file(GLOB MyVar var/*.png) | ||||
| install(FILES ${MyVar} DESTINATION share/slic3r-prusa3d) | ||||
| 
 | ||||
| # Resources install target, configure fhs.hpp on UNIX | ||||
| if (WIN32) | ||||
|     install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources") | ||||
| else () | ||||
|     set(SLIC3R_FHS_RESOURCES "${CMAKE_INSTALL_FULL_DATAROOTDIR}/slic3r-prusa3d") | ||||
|     install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${SLIC3R_FHS_RESOURCES}") | ||||
| endif () | ||||
| configure_file(${LIBDIR}/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/platform/unix/fhs.hpp) | ||||
|  |  | |||
|  | @ -33,6 +33,7 @@ if(PNG_FOUND AND NOT RASTERIZER_FORCE_BUILTIN_LIBPNG) | |||
| else() | ||||
|     set(ZLIB_LIBRARY "") | ||||
|     message(WARNING "Using builtin libpng. This can cause crashes on some platforms.") | ||||
|     set(SKIP_INSTALL_ALL 1)   # Prevent png+zlib from creating install targets | ||||
|     add_subdirectory(png/zlib) | ||||
|     set(ZLIB_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/png/zlib ${CMAKE_CURRENT_BINARY_DIR}/png/zlib) | ||||
|     include_directories(${ZLIB_INCLUDE_DIR}) | ||||
|  | @ -188,3 +189,15 @@ else () | |||
|         VERBATIM | ||||
|     ) | ||||
| endif() | ||||
| 
 | ||||
| # Slic3r binary install target | ||||
| if (WIN32) | ||||
|     install(TARGETS slic3r RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}") | ||||
|     if (MSVC) | ||||
|         install(TARGETS slic3r_app_gui RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}") | ||||
|         install(TARGETS slic3r_app_console RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}") | ||||
|         install(TARGETS slic3r_app_noconsole RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}") | ||||
|     endif () | ||||
| else () | ||||
|     install(TARGETS slic3r RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") | ||||
| endif () | ||||
|  |  | |||
							
								
								
									
										2
									
								
								src/platform/unix/fhs.hpp.in
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/platform/unix/fhs.hpp.in
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| #cmakedefine SLIC3R_FHS @SLIC3R_FHS@ | ||||
| #define SLIC3R_FHS_RESOURCES "@SLIC3R_FHS_RESOURCES@" | ||||
|  | @ -22,6 +22,8 @@ | |||
| #include <boost/nowide/cenv.hpp> | ||||
| #include <boost/nowide/iostream.hpp> | ||||
| 
 | ||||
| #include "unix/fhs.hpp"  // Generated by CMake from ../platform/unix/fhs.hpp.in
 | ||||
| 
 | ||||
| #include "libslic3r/libslic3r.h" | ||||
| #include "libslic3r/Config.hpp" | ||||
| #include "libslic3r/Geometry.hpp" | ||||
|  | @ -77,6 +79,10 @@ int main(int argc, char **argv) | |||
|     // The resources are packed to 'resources'
 | ||||
|     // Path from Slic3r binary to resources:
 | ||||
|     boost::filesystem::path path_resources = path_to_binary.parent_path() / "resources"; | ||||
| #elif defined SLIC3R_FHS | ||||
|     // The application is packaged according to the Linux Filesystem Hierarchy Standard
 | ||||
|     // Resources are set to the 'Architecture-independent (shared) data', typically /usr/share or /usr/local/share
 | ||||
|     boost::filesystem::path path_resources = SLIC3R_FHS_RESOURCES; | ||||
| #else | ||||
|     // The application is packed in the .tar.bz archive (or in AppImage) as 'bin/slic3r',
 | ||||
|     // The resources are packed to 'resources'
 | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
| 
 | ||||
| #include <boost/lexical_cast.hpp> | ||||
| #include <boost/algorithm/string.hpp> | ||||
| #include <boost/filesystem.hpp> | ||||
| 
 | ||||
| #include <wx/stdpaths.h> | ||||
| #include <wx/imagpng.h> | ||||
|  | @ -15,6 +14,7 @@ | |||
| #include <wx/filedlg.h> | ||||
| #include <wx/dir.h> | ||||
| #include <wx/wupdlock.h> | ||||
| #include <wx/filefn.h> | ||||
| 
 | ||||
| #include "libslic3r/Utils.hpp" | ||||
| #include "libslic3r/Model.hpp" | ||||
|  | @ -83,6 +83,11 @@ GUI_App::GUI_App() | |||
| 
 | ||||
| bool GUI_App::OnInit() | ||||
| { | ||||
|     // Verify resources path
 | ||||
|     const wxString resources_dir = from_u8(Slic3r::resources_dir()); | ||||
|     wxCHECK_MSG(wxDirExists(resources_dir), false, | ||||
|         wxString::Format("Resources path does not exist or is not a directory: %s", resources_dir)); | ||||
| 
 | ||||
| #if ENABLE_IMGUI | ||||
|     wxCHECK_MSG(m_imgui->init(), false, "Failed to initialize ImGui"); | ||||
| #endif // ENABLE_IMGUI
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vojtech Kral
						Vojtech Kral