Skip to content

Commit

Permalink
[SDK} read lib3mf version in CMakeLists.txt from environment variable…
Browse files Browse the repository at this point in the history
… LIB3MF_VERSION
  • Loading branch information
3dJan committed Jun 10, 2024
1 parent 23a5c5c commit 8ff5810
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 9 additions & 3 deletions SDK/CPackExamples/Cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@ cmake_minimum_required (VERSION 3.5)
project(Examples)
set(CMAKE_CXX_STANDARD 11)

# read the version of the 3MF Library from en environment variable LIB3MF_VERSION
if (DEFINED ENV{LIB3MF_VERSION})
set(LIB3MF_VERSION $ENV{LIB3MF_VERSION})
else()
set(LIB3MF_VERSION "2.3.1")

# Determine the platform and set lib3mf_DIR accordingly
if(WIN32)
# Path for Windows
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-2.3.1-Windows/lib/cmake/lib3mf")
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-${LIB3MF_VERSION}-Windows/lib/cmake/lib3mf")
find_package(lib3mf REQUIRED COMPONENTS Cpp)
elseif(APPLE)
# Path for macOS (Darwin)
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-2.3.1-Darwin/lib/cmake/lib3mf")
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-${LIB3MF_VERSION}-Darwin/lib/cmake/lib3mf")
find_package(lib3mf REQUIRED COMPONENTS Cpp)
else()
# Path for Linux (Here we check twice to test for Debian / RPM packages properly)
find_package(lib3mf QUIET COMPONENTS Cpp)
# Check if the package was not found
if(NOT lib3mf_FOUND)
# lib3mf not found, so set lib3mf_DIR to the fallback directory
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-2.3.1-Linux/lib/cmake/lib3mf")
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-${LIB3MF_VERSION}-Linux/lib/cmake/lib3mf")
# Find package (lib3mf)
find_package(lib3mf REQUIRED COMPONENTS Cpp)
endif()
Expand Down
13 changes: 10 additions & 3 deletions SDK/CPackExamples/CppDynamic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,29 @@ cmake_minimum_required(VERSION 3.5)
project(Example_ExtractInfo)
set(CMAKE_CXX_STANDARD 11)


# read the version of the 3MF Library from en environment variable LIB3MF_VERSION
if (DEFINED ENV{LIB3MF_VERSION})
set(LIB3MF_VERSION $ENV{LIB3MF_VERSION})
else()
set(LIB3MF_VERSION "2.3.1")

# Determine the platform and set lib3mf_DIR accordingly
if(WIN32)
# Path for Windows
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-2.3.1-Windows/lib/cmake/lib3mf")
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-${LIB3MF_VERSION}-Windows/lib/cmake/lib3mf")
find_package(lib3mf REQUIRED COMPONENTS CppDynamic)
elseif(APPLE)
# Path for macOS (Darwin)
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-2.3.1-Darwin/lib/cmake/lib3mf")
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-${LIB3MF_VERSION}-Darwin/lib/cmake/lib3mf")
find_package(lib3mf REQUIRED COMPONENTS CppDynamic)
else()
# Path for Linux (Here we check twice to test for Debian / RPM packages properly)
find_package(lib3mf QUIET COMPONENTS CppDynamic)
# Check if the package was not found
if(NOT lib3mf_FOUND)
# lib3mf not found, so set lib3mf_DIR to the fallback directory
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-2.3.1-Linux/lib/cmake/lib3mf")
set(lib3mf_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib3mf-${LIB3MF_VERSION}-Linux/lib/cmake/lib3mf")
# Find package (lib3mf)
find_package(lib3mf REQUIRED COMPONENTS CppDynamic)
endif()
Expand Down

0 comments on commit 8ff5810

Please sign in to comment.