diff --git a/CMakeLists.txt b/CMakeLists.txt index 45463abdd..ac2e64222 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ project(Slic3r) cmake_minimum_required(VERSION 3.2) +include("version.inc") +set(SLIC3R_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") + if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE) @@ -108,12 +111,12 @@ if (0) message("Old CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") message("Old CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELEASE}") message("Old CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS_RELEASE}") - set(CMAKE_CXX_FLAGS_RELEASE "/MD /Od /Zi /EHsc /DNDEBUG /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_C_FLAGS_RELEASE "/MD /Od /Zi /DNDEBUG /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Od /Zi /EHsc /DNDEBUG /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MD /Od /Zi /DNDEBUG /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_CXX_FLAGS "/MD /Od /Zi /EHsc /DNDEBUG /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_C_FLAGS "/MD /Od /Zi /DNDEBUG /DWIN32 /DTBB_USE_ASSERT") + set(CMAKE_CXX_FLAGS_RELEASE "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT") + set(CMAKE_C_FLAGS_RELEASE "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT") + set(CMAKE_CXX_FLAGS "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT") + set(CMAKE_C_FLAGS "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT") endif() # Find and configure boost diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40bda7aad..b19c5cd02 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,9 +53,11 @@ endif() add_subdirectory(slic3r) # Create a slic3r executable -#FIXME add Windows resource file -#add_executable(slic3r slic3r.cpp slic3r.rc) -add_executable(slic3r slic3r.cpp) +# Process mainfests for various platforms. +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/slic3r.rc.in ${CMAKE_CURRENT_BINARY_DIR}/slic3r.rc @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/slic3r.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/slic3r.manifest @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/osx/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY) +add_executable(slic3r slic3r.cpp ${CMAKE_CURRENT_BINARY_DIR}/slic3r.rc) if(SLIC3R_GUI) set_target_properties(slic3r PROPERTIES OUTPUT_NAME "slic3r-gui") else() @@ -67,7 +69,10 @@ if (APPLE) # add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE) # -liconv: boost links to libiconv by default target_link_libraries(slic3r "-liconv -framework IOKit" "-framework CoreFoundation" -lc++) -elseif (NOT MSVC) +elseif (MSVC) + # Manifest is provided through slic3r.rc, don't generate your own. + set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) +else () target_link_libraries(slic3r -ldl -lstdc++) endif () diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 16b70a8da..b5974489d 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -1,6 +1,8 @@ project(libslic3r) cmake_minimum_required(VERSION 2.6) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libslic3r_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.h @ONLY) + add_library(libslic3r STATIC BoundingBox.cpp BoundingBox.hpp @@ -96,6 +98,7 @@ add_library(libslic3r STATIC Layer.hpp LayerRegion.cpp libslic3r.h + "${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.h" Line.cpp Line.hpp Model.cpp @@ -149,7 +152,7 @@ add_library(libslic3r STATIC ) target_compile_definitions(libslic3r PUBLIC -DUSE_TBB ${PNG_DEFINITIONS}) -target_include_directories(libslic3r PUBLIC BEFORE ${LIBNEST2D_INCLUDES} ${PNG_INCLUDE_DIRS}) +target_include_directories(libslic3r PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${LIBNEST2D_INCLUDES} ${PNG_INCLUDE_DIRS}) target_link_libraries(libslic3r ${LIBNEST2D_LIBRARIES} admesh diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h index 5f2f3fba1..a2ee3fc9f 100644 --- a/src/libslic3r/libslic3r.h +++ b/src/libslic3r/libslic3r.h @@ -1,6 +1,8 @@ #ifndef _libslic3r_h_ #define _libslic3r_h_ +#include "libslic3r_version.h" + // this needs to be included early for MSVC (listing it in Build.PL is not enough) #include #include @@ -15,10 +17,6 @@ #include "Technologies.hpp" -#define SLIC3R_FORK_NAME "Slic3r Prusa Edition" -#define SLIC3R_VERSION "1.41.0" -#define SLIC3R_BUILD "UNKNOWN" - typedef int32_t coord_t; typedef double coordf_t; diff --git a/src/libslic3r/libslic3r_version.h.in b/src/libslic3r/libslic3r_version.h.in new file mode 100644 index 000000000..2259b2302 --- /dev/null +++ b/src/libslic3r/libslic3r_version.h.in @@ -0,0 +1,8 @@ +#ifndef __SLIC3R_VERSION_H +#define __SLIC3R_VERSION_H + +#define SLIC3R_FORK_NAME "@SLIC3R_FORK_NAME@" +#define SLIC3R_VERSION "@SLIC3R_VERSION@" +#define SLIC3R_BUILD "@SLIC3R_BUILD@" + +#endif /* __SLIC3R_VERSION_H */ diff --git a/src/slic3r.manifest b/src/platform/msw/slic3r.manifest.in similarity index 95% rename from src/slic3r.manifest rename to src/platform/msw/slic3r.manifest.in index c480ca337..ab1cc5ae2 100644 --- a/src/slic3r.manifest +++ b/src/platform/msw/slic3r.manifest.in @@ -1,6 +1,6 @@ - + Perl diff --git a/src/slic3r.rc b/src/platform/msw/slic3r.rc.in similarity index 70% rename from src/slic3r.rc rename to src/platform/msw/slic3r.rc.in index 7ae8653dd..493f9f752 100644 --- a/src/slic3r.rc +++ b/src/platform/msw/slic3r.rc.in @@ -1,6 +1,6 @@ 1 VERSIONINFO -FILEVERSION SLIC3R_RC_VERSION -PRODUCTVERSION SLIC3R_RC_VERSION +FILEVERSION @SLIC3R_RC_VERSION@ +PRODUCTVERSION @SLIC3R_RC_VERSION@ { BLOCK "StringFileInfo" { @@ -8,9 +8,9 @@ PRODUCTVERSION SLIC3R_RC_VERSION { VALUE "CompanyName", "Prusa Research" VALUE "FileDescription", "Slic3r Prusa Edition" - VALUE "FileVersion", "SLIC3R_BUILD_ID" + VALUE "FileVersion", "@SLIC3R_BUILD_ID@" VALUE "ProductName", "Slic3r Prusa Edition" - VALUE "ProductVersion", "SLIC3R_BUILD_ID" + VALUE "ProductVersion", "@SLIC3R_BUILD_ID@" VALUE "InternalName", "Slic3r Prusa Edition" VALUE "LegalCopyright", "Copyright \251 2011-2017 Alessandro Ranelucci, \251 2016 Prusa Research" VALUE "OriginalFilename", "slic3r.exe" @@ -21,5 +21,5 @@ PRODUCTVERSION SLIC3R_RC_VERSION VALUE "Translation", 0x409, 1252 } } -2 ICON "../resources/icons/Slic3r.ico" +2 ICON "@SLIC3R_RESOURCES_DIR@/icons/Slic3r.ico" 1 24 "slic3r.manifest" diff --git a/src/platform/osx/Info.plist.in b/src/platform/osx/Info.plist.in new file mode 100644 index 000000000..099cb5c37 --- /dev/null +++ b/src/platform/osx/Info.plist.in @@ -0,0 +1,32 @@ + + + + + CFBundleExecutable + Slic3r + CFBundleGetInfoString + Slic3r Copyright (C) 2011-2017 Alessandro Ranellucci, (C) 2016-2018 Prusa Reseach + CFBundleIconFile + Slic3r.icns + CFBundleName + Slic3r + CFBundleShortVersionString + Slic3r @SLIC3R_BUILD_ID@ + CFBundleIdentifier + com.prusa3d.slic3r/ + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + @SLIC3R_BUILD_ID@ + CGDisableCoalescedUpdates + + NSPrincipalClass + NSApplication + NSHighResolutionCapable + + + diff --git a/src/slic3r.cpp b/src/slic3r.cpp index 35ec62316..29e1e28e9 100644 --- a/src/slic3r.cpp +++ b/src/slic3r.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #ifdef USE_WX @@ -48,6 +49,16 @@ int main(int argc, char **argv) //FIXME On Windows, we want to receive the arguments as 16bit characters! boost::nowide::args a(argc, argv); + { + const char *loglevel = boost::nowide::getenv("SLIC3R_LOGLEVEL"); + if (loglevel != nullptr) { + if (loglevel[0] >= '0' && loglevel[0] <= '9' && loglevel[1] == 0) + set_logging_level(loglevel[0] - '0'); + else + boost::nowide::cerr << "Invalid SLIC3R_LOGLEVEL environment variable: " << loglevel << std::endl; + } + } + // parse all command line options into a DynamicConfig DynamicPrintAndCLIConfig config; t_config_option_keys input_files; @@ -89,7 +100,7 @@ int main(int argc, char **argv) // apply command line options to a more handy CLIConfig CLIConfig cli_config; cli_config.apply(config, true); - set_local_dir(cli_config.datadir.value); + set_data_dir(cli_config.datadir.value); DynamicPrintConfig print_config; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index c8a32208f..e97eab7ae 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -116,10 +116,15 @@ void MainFrame::init_tabpanel() auto panel = m_tabpanel->GetCurrentPage(); // panel->OnActivate(); if panel->can('OnActivate'); - std::vector tab_names = { "print", "filament", "printer" }; - for (auto& tab_name : tab_names) { - if (tab_name == panel->GetName()) - m_options_tabs.at(tab_name)->OnActivate(); + for (auto& tab_name : { "print", "filament", "printer" }) { + if (tab_name == panel->GetName()) { + // On GTK, the wxEVT_NOTEBOOK_PAGE_CHANGED event is triggered + // before the MainFrame is fully set up. + auto it = m_options_tabs.find(tab_name); + assert(it != m_options_tabs.end()); + if (it != m_options_tabs.end()) + it->second->OnActivate(); + } } }); diff --git a/version.inc b/version.inc new file mode 100644 index 000000000..5a23105a8 --- /dev/null +++ b/version.inc @@ -0,0 +1,9 @@ +# Included by CMakeLists, edited by the build script +# (the version numbers are generated by the build script from the git current label) + +set(SLIC3R_FORK_NAME "Slic3r Prusa Edition") +set(SLIC3R_VERSION "1.42.0-alpha") +set(SLIC3R_BUILD "UNKNOWN") +set(SLIC3R_RC_VERSION "1,42,0,0") +set(SLIC3R_RC_VERSION_DOTS "1.42.0.0") +set(SLIC3R_BUILD_ID "${SLIC3R_VERSION}+${SLIC3R_BUILD}")