Skip to content

Commit f8ec5fc

Browse files
committed
Revert CMAKE_FIND_PACKAGE_PREFER_CONFIG as its from cmake > 3.13
Do the overriding in the appropriate find modules in cmake/modules
1 parent 6365e54 commit f8ec5fc

File tree

2 files changed

+88
-86
lines changed

2 files changed

+88
-86
lines changed

CMakeLists.txt

+2-19
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ set(SLIC3R_GTK "2" CACHE STRING "GTK version to use with wxWidgets on Linux")
4343

4444
set(IS_CROSS_COMPILE FALSE)
4545

46-
if (SLIC3R_STATIC)
47-
# Prefer config scripts over find modules. This is helpful when building with
48-
# the static dependencies. Many libraries have their own export scripts
49-
# while having a Find<PkgName> module in standard cmake installation.
50-
# (e.g. CURL)
51-
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
52-
endif ()
53-
5446
if (APPLE)
5547
set(CMAKE_FIND_FRAMEWORK LAST)
5648
set(CMAKE_FIND_APPBUNDLE LAST)
@@ -458,19 +450,10 @@ if (NOT EIGEN3_FOUND)
458450
endif ()
459451
include_directories(BEFORE SYSTEM ${EIGEN3_INCLUDE_DIR})
460452

461-
# Find expat or use bundled version
462-
# Always use the system libexpat on Linux.
463-
453+
# Find expat. We have our overriden FindEXPAT which exports libexpat target
454+
# no matter what.
464455
find_package(EXPAT REQUIRED)
465456

466-
add_library(libexpat INTERFACE)
467-
468-
if (TARGET EXPAT::EXPAT )
469-
target_link_libraries(libexpat INTERFACE EXPAT::EXPAT)
470-
elseif(TARGET expat::expat)
471-
target_link_libraries(libexpat INTERFACE expat::expat)
472-
endif ()
473-
474457
find_package(PNG REQUIRED)
475458

476459
set(OpenGL_GL_PREFERENCE "LEGACY")

cmake/modules/FindCURL.cmake

+86-67
Original file line numberDiff line numberDiff line change
@@ -30,82 +30,101 @@
3030
# ``CURL_VERSION_STRING``
3131
# The version of curl found.
3232

33-
# Look for the header file.
34-
find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
35-
mark_as_advanced(CURL_INCLUDE_DIR)
33+
# First, prefer config scripts
34+
set(_q "")
35+
if(CURL_FIND_QUIETLY)
36+
set(_q QUIET)
37+
endif()
38+
find_package(CURL ${CURL_FIND_VERSION} CONFIG ${_q})
3639

37-
if(NOT CURL_LIBRARY)
38-
# Look for the library (sorted from most current/relevant entry to least).
39-
find_library(CURL_LIBRARY_RELEASE NAMES
40-
curl
41-
# Windows MSVC prebuilts:
42-
curllib
43-
libcurl_imp
44-
curllib_static
45-
# Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
46-
libcurl
47-
# Static library on Windows
48-
libcurl_a
49-
)
50-
mark_as_advanced(CURL_LIBRARY_RELEASE)
40+
if(NOT CURL_FIND_QUIETLY)
41+
if (NOT CURL_FOUND)
42+
message(STATUS "Falling back to MODULE search for CURL...")
43+
else()
44+
message(STATUS "CURL found in ${CURL_DIR}")
45+
endif()
46+
endif()
5147

52-
find_library(CURL_LIBRARY_DEBUG NAMES
53-
# Windows MSVC CMake builds in debug configuration on vcpkg:
54-
libcurl-d_imp
55-
libcurl-d
56-
# Static library on Windows, compiled in debug mode
57-
libcurl_a_debug
58-
)
59-
mark_as_advanced(CURL_LIBRARY_DEBUG)
48+
if (NOT CURL_FOUND)
6049

61-
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations_SLIC3R.cmake)
62-
select_library_configurations_SLIC3R(CURL)
63-
endif()
50+
# Look for the header file.
51+
find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
52+
mark_as_advanced(CURL_INCLUDE_DIR)
6453

65-
if(CURL_INCLUDE_DIR)
66-
foreach(_curl_version_header curlver.h curl.h)
67-
if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
68-
file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
54+
if(NOT CURL_LIBRARY)
55+
# Look for the library (sorted from most current/relevant entry to least).
56+
find_library(CURL_LIBRARY_RELEASE NAMES
57+
curl
58+
# Windows MSVC prebuilts:
59+
curllib
60+
libcurl_imp
61+
curllib_static
62+
# Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
63+
libcurl
64+
# Static library on Windows
65+
libcurl_a
66+
)
67+
mark_as_advanced(CURL_LIBRARY_RELEASE)
6968

70-
string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}")
71-
unset(curl_version_str)
72-
break()
73-
endif()
74-
endforeach()
75-
endif()
69+
find_library(CURL_LIBRARY_DEBUG NAMES
70+
# Windows MSVC CMake builds in debug configuration on vcpkg:
71+
libcurl-d_imp
72+
libcurl-d
73+
# Static library on Windows, compiled in debug mode
74+
libcurl_a_debug
75+
)
76+
mark_as_advanced(CURL_LIBRARY_DEBUG)
7677

77-
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs_SLIC3R.cmake)
78-
FIND_PACKAGE_HANDLE_STANDARD_ARGS_SLIC3R(CURL
79-
REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
80-
VERSION_VAR CURL_VERSION_STRING)
78+
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations_SLIC3R.cmake)
79+
select_library_configurations_SLIC3R(CURL)
80+
endif()
8181

82-
if(CURL_FOUND)
83-
set(CURL_LIBRARIES ${CURL_LIBRARY})
84-
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
82+
if(CURL_INCLUDE_DIR)
83+
foreach(_curl_version_header curlver.h curl.h)
84+
if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
85+
file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
8586

86-
if(NOT TARGET CURL::libcurl)
87-
add_library(CURL::libcurl UNKNOWN IMPORTED)
88-
set_target_properties(CURL::libcurl PROPERTIES
89-
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")
87+
string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}")
88+
unset(curl_version_str)
89+
break()
90+
endif()
91+
endforeach()
92+
endif()
9093

91-
if(EXISTS "${CURL_LIBRARY}")
92-
set_target_properties(CURL::libcurl PROPERTIES
93-
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
94-
IMPORTED_LOCATION "${CURL_LIBRARY}")
95-
endif()
96-
if(CURL_LIBRARY_RELEASE)
97-
set_property(TARGET CURL::libcurl APPEND PROPERTY
98-
IMPORTED_CONFIGURATIONS RELEASE)
99-
set_target_properties(CURL::libcurl PROPERTIES
100-
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
101-
IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}")
102-
endif()
103-
if(CURL_LIBRARY_DEBUG)
104-
set_property(TARGET CURL::libcurl APPEND PROPERTY
105-
IMPORTED_CONFIGURATIONS DEBUG)
94+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs_SLIC3R.cmake)
95+
FIND_PACKAGE_HANDLE_STANDARD_ARGS_SLIC3R(CURL
96+
REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
97+
VERSION_VAR CURL_VERSION_STRING)
98+
99+
if(CURL_FOUND)
100+
set(CURL_LIBRARIES ${CURL_LIBRARY})
101+
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
102+
103+
if(NOT TARGET CURL::libcurl)
104+
add_library(CURL::libcurl UNKNOWN IMPORTED)
106105
set_target_properties(CURL::libcurl PROPERTIES
107-
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
108-
IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}")
106+
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")
107+
108+
if(EXISTS "${CURL_LIBRARY}")
109+
set_target_properties(CURL::libcurl PROPERTIES
110+
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
111+
IMPORTED_LOCATION "${CURL_LIBRARY}")
112+
endif()
113+
if(CURL_LIBRARY_RELEASE)
114+
set_property(TARGET CURL::libcurl APPEND PROPERTY
115+
IMPORTED_CONFIGURATIONS RELEASE)
116+
set_target_properties(CURL::libcurl PROPERTIES
117+
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
118+
IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}")
119+
endif()
120+
if(CURL_LIBRARY_DEBUG)
121+
set_property(TARGET CURL::libcurl APPEND PROPERTY
122+
IMPORTED_CONFIGURATIONS DEBUG)
123+
set_target_properties(CURL::libcurl PROPERTIES
124+
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
125+
IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}")
126+
endif()
109127
endif()
110128
endif()
111-
endif()
129+
130+
endif (NOT CURL_FOUND)

0 commit comments

Comments
 (0)