Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2019-10-14 13:50:08 +0300
committertamasmeszaros <meszaros.q@gmail.com>2019-10-14 13:50:08 +0300
commitfbc174ad061a0c6dbbd2cc66455e4bd949517af3 (patch)
treed2a33f32b056d274b008ee2066ce84736fbfa485 /cmake
parent62b7892fa112a5ee7fef62aec5a48276419685ea (diff)
Fix cmake with msvc generator.
* Remove unused libnest2d files. Make it use the global build script targets. * Modify FindTBB to address multi-config builds and take care of __TBB_NO_IMPLICIT_LINKAGE * Move FindNLopt to project common cmake module dir * Rename libnest.hpp to nester.hpp and libnest.h to libnest.hpp * Clean up common test suite build scripts
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindNLopt.cmake130
-rw-r--r--cmake/modules/FindTBB.cmake32
2 files changed, 141 insertions, 21 deletions
diff --git a/cmake/modules/FindNLopt.cmake b/cmake/modules/FindNLopt.cmake
new file mode 100644
index 000000000..912ce8d30
--- /dev/null
+++ b/cmake/modules/FindNLopt.cmake
@@ -0,0 +1,130 @@
+#///////////////////////////////////////////////////////////////////////////
+#//-------------------------------------------------------------------------
+#//
+#// Description:
+#// cmake module for finding NLopt installation
+#// NLopt installation location is defined by environment variable $NLOPT
+#//
+#// following variables are defined:
+#// NLopt_DIR - NLopt installation directory
+#// NLopt_INCLUDE_DIR - NLopt header directory
+#// NLopt_LIBRARY_DIR - NLopt library directory
+#// NLopt_LIBS - NLopt library files
+#//
+#// Example usage:
+#// find_package(NLopt 1.4 REQUIRED)
+#//
+#//
+#//-------------------------------------------------------------------------
+
+
+set(NLopt_FOUND FALSE)
+set(NLopt_ERROR_REASON "")
+set(NLopt_DEFINITIONS "")
+unset(NLopt_LIBS CACHE)
+
+set(NLopt_DIR $ENV{NLOPT})
+if(NOT NLopt_DIR)
+
+ set(NLopt_FOUND TRUE)
+
+ set(_NLopt_LIB_NAMES "nlopt")
+ find_library(NLopt_LIBS
+ NAMES ${_NLopt_LIB_NAMES})
+ if(NOT NLopt_LIBS)
+ set(NLopt_FOUND FALSE)
+ set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Cannot find NLopt library '${_NLopt_LIB_NAMES}'.")
+ else()
+ get_filename_component(NLopt_DIR ${NLopt_LIBS} PATH)
+ endif()
+ unset(_NLopt_LIB_NAMES)
+
+ set(_NLopt_HEADER_FILE_NAME "nlopt.hpp")
+ find_file(_NLopt_HEADER_FILE
+ NAMES ${_NLopt_HEADER_FILE_NAME})
+ if(NOT _NLopt_HEADER_FILE)
+ set(NLopt_FOUND FALSE)
+ set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Cannot find NLopt header file '${_NLopt_HEADER_FILE_NAME}'.")
+ endif()
+ unset(_NLopt_HEADER_FILE_NAME)
+
+ if(NOT NLopt_FOUND)
+ set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} NLopt not found in system directories (and environment variable NLOPT is not set).")
+ else()
+ get_filename_component(NLopt_INCLUDE_DIR ${_NLopt_HEADER_FILE} DIRECTORY )
+ endif()
+
+ unset(_NLopt_HEADER_FILE CACHE)
+
+else()
+
+ set(NLopt_FOUND TRUE)
+
+ set(NLopt_INCLUDE_DIR "${NLopt_DIR}/include")
+ if(NOT EXISTS "${NLopt_INCLUDE_DIR}")
+ set(NLopt_FOUND FALSE)
+ set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Directory '${NLopt_INCLUDE_DIR}' does not exist.")
+ endif()
+
+ set(NLopt_LIBRARY_DIR "${NLopt_DIR}/lib")
+ if(NOT EXISTS "${NLopt_LIBRARY_DIR}")
+ set(NLopt_FOUND FALSE)
+ set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Directory '${NLopt_LIBRARY_DIR}' does not exist.")
+ endif()
+
+ set(_NLopt_LIB_NAMES "nlopt_cxx")
+ find_library(NLopt_LIBS
+ NAMES ${_NLopt_LIB_NAMES}
+ PATHS ${NLopt_LIBRARY_DIR}
+ NO_DEFAULT_PATH)
+ if(NOT NLopt_LIBS)
+ set(NLopt_FOUND FALSE)
+ set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Cannot find NLopt library '${_NLopt_LIB_NAMES}' in '${NLopt_LIBRARY_DIR}'.")
+ endif()
+ unset(_NLopt_LIB_NAMES)
+
+ set(_NLopt_HEADER_FILE_NAME "nlopt.hpp")
+ find_file(_NLopt_HEADER_FILE
+ NAMES ${_NLopt_HEADER_FILE_NAME}
+ PATHS ${NLopt_INCLUDE_DIR}
+ NO_DEFAULT_PATH)
+ if(NOT _NLopt_HEADER_FILE)
+ set(NLopt_FOUND FALSE)
+ set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Cannot find NLopt header file '${_NLopt_HEADER_FILE_NAME}' in '${NLopt_INCLUDE_DIR}'.")
+ endif()
+ unset(_NLopt_HEADER_FILE_NAME)
+ unset(_NLopt_HEADER_FILE CACHE)
+
+endif()
+
+
+# make variables changeable
+mark_as_advanced(
+ NLopt_INCLUDE_DIR
+ NLopt_LIBRARY_DIR
+ NLopt_LIBS
+ NLopt_DEFINITIONS
+ )
+
+
+# report result
+if(NLopt_FOUND)
+ message(STATUS "Found NLopt in '${NLopt_DIR}'.")
+ message(STATUS "Using NLopt include directory '${NLopt_INCLUDE_DIR}'.")
+ message(STATUS "Using NLopt library '${NLopt_LIBS}'.")
+ add_library(NLopt::nlopt INTERFACE IMPORTED)
+ set_target_properties(NLopt::nlopt PROPERTIES INTERFACE_LINK_LIBRARIES ${NLopt_LIBS})
+ set_target_properties(NLopt::nlopt PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${NLopt_INCLUDE_DIR})
+ set_target_properties(NLopt::nlopt PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${NLopt_DEFINITIONS}")
+ # target_link_libraries(Nlopt::Nlopt INTERFACE ${NLopt_LIBS})
+ # target_include_directories(Nlopt::Nlopt INTERFACE ${NLopt_INCLUDE_DIR})
+ # target_compile_definitions(Nlopt::Nlopt INTERFACE ${NLopt_DEFINITIONS})
+else()
+ if(NLopt_FIND_REQUIRED)
+ message(FATAL_ERROR "Unable to find requested NLopt installation:${NLopt_ERROR_REASON}")
+ else()
+ if(NOT NLopt_FIND_QUIETLY)
+ message(STATUS "NLopt was not found:${NLopt_ERROR_REASON}")
+ endif()
+ endif()
+endif()
diff --git a/cmake/modules/FindTBB.cmake b/cmake/modules/FindTBB.cmake
index e5115ab44..153e615eb 100644
--- a/cmake/modules/FindTBB.cmake
+++ b/cmake/modules/FindTBB.cmake
@@ -250,26 +250,23 @@ if(NOT TBB_FOUND)
endif()
endforeach()
- unset(TBB_STATIC_SUFFIX)
-
##################################
# Set compile flags and libraries
##################################
set(TBB_DEFINITIONS_RELEASE "")
- set(TBB_DEFINITIONS_DEBUG "-DTBB_USE_DEBUG=1")
+ set(TBB_DEFINITIONS_DEBUG "TBB_USE_DEBUG=1")
if(TBB_LIBRARIES_${TBB_BUILD_TYPE})
- set(TBB_DEFINITIONS "${TBB_DEFINITIONS_${TBB_BUILD_TYPE}}")
set(TBB_LIBRARIES "${TBB_LIBRARIES_${TBB_BUILD_TYPE}}")
- elseif(TBB_LIBRARIES_RELEASE)
- set(TBB_DEFINITIONS "${TBB_DEFINITIONS_RELEASE}")
- set(TBB_LIBRARIES "${TBB_LIBRARIES_RELEASE}")
- elseif(TBB_LIBRARIES_DEBUG)
- set(TBB_DEFINITIONS "${TBB_DEFINITIONS_DEBUG}")
- set(TBB_LIBRARIES "${TBB_LIBRARIES_DEBUG}")
endif()
+ if (MSVC AND TBB_STATIC)
+ set(TBB_DEFINITIONS __TBB_NO_IMPLICIT_LINKAGE)
+ endif ()
+
+ unset (TBB_STATIC_SUFFIX)
+
find_package_handle_standard_args(TBB
REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARIES
HANDLE_COMPONENTS
@@ -280,25 +277,18 @@ if(NOT TBB_FOUND)
##################################
if(NOT CMAKE_VERSION VERSION_LESS 3.0 AND TBB_FOUND)
- add_library(tbb UNKNOWN IMPORTED)
- set_target_properties(tbb PROPERTIES
+ add_library(TBB::tbb UNKNOWN IMPORTED)
+ set_target_properties(TBB::tbb PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS}
IMPORTED_LOCATION ${TBB_LIBRARIES})
if(TBB_LIBRARIES_RELEASE AND TBB_LIBRARIES_DEBUG)
- set_target_properties(tbb PROPERTIES
- INTERFACE_COMPILE_DEFINITIONS "$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:TBB_USE_DEBUG=1>"
+ set_target_properties(TBB::tbb PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS};$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:${TBB_DEFINITIONS_DEBUG}>;$<$<CONFIG:Release>:${TBB_DEFINITIONS_RELEASE}>"
IMPORTED_LOCATION_DEBUG ${TBB_LIBRARIES_DEBUG}
IMPORTED_LOCATION_RELWITHDEBINFO ${TBB_LIBRARIES_RELEASE}
IMPORTED_LOCATION_RELEASE ${TBB_LIBRARIES_RELEASE}
IMPORTED_LOCATION_MINSIZEREL ${TBB_LIBRARIES_RELEASE}
)
- elseif(TBB_LIBRARIES_RELEASE)
- set_target_properties(tbb PROPERTIES IMPORTED_LOCATION ${TBB_LIBRARIES_RELEASE})
- else()
- set_target_properties(tbb PROPERTIES
- INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS_DEBUG}"
- IMPORTED_LOCATION ${TBB_LIBRARIES_DEBUG}
- )
endif()
endif()