Skip to content

Commit 1b9a28d

Browse files
Stinkfist0aothms
authored andcommitted
CMakeLists.txt: fix Windows/MSVC lib search when only Debug versions of libs are found.
1 parent 68b432f commit 1b9a28d

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

cmake/CMakeLists.txt

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,12 @@ ELSE()
189189
ENDIF()
190190

191191
# Use the found libTKernel as a template for all other OCC libraries
192+
# TODO Extract this into macro/function
192193
foreach(lib ${OPENCASCADE_LIBRARY_NAMES})
193-
string(REPLACE TKernel "${lib}" lib_path "${libTKernel}")
194-
list(APPEND OPENCASCADE_LIBRARIES "${lib_path}")
194+
# Make sure we'll handle the Windows/MSVC debug postfix convetion too.
195+
string(REPLACE TKerneld "${lib}" lib_path "${libTKernel}")
196+
string(REPLACE TKernel "${lib}" lib_path "${lib_path}")
197+
list(APPEND OPENCASCADE_LIBRARIES "${lib_path}")
195198
endforeach()
196199

197200
if(MSVC)
@@ -251,7 +254,13 @@ IF(COLLADA_SUPPORT)
251254
GET_FILENAME_COMPONENT(OPENCOLLADA_LIBRARY_DIR ${OPENCOLLADA_FRAMEWORK_LIB} PATH)
252255
ENDIF()
253256

254-
FIND_LIBRARY(OpenCOLLADAFramework NAMES OpenCOLLADAFramework PATHS ${OPENCOLLADA_LIBRARY_DIR} NO_DEFAULT_PATH)
257+
FIND_LIBRARY(OpenCOLLADAFramework NAMES OpenCOLLADAFramework OpenCOLLADAFrameworkd PATHS ${OPENCOLLADA_LIBRARY_DIR} NO_DEFAULT_PATH)
258+
if (OpenCOLLADAFramework)
259+
message(STATUS "OpenCOLLADA library files found")
260+
else()
261+
message(FATAL_ERROR "COLLADA_SUPPORT enabled, but unable to find OpenCOLLADA libraries. "
262+
"Disable COLLADA_SUPPORT or fix OpenCOLLADA paths to proceed.")
263+
endif()
255264

256265
SET(OPENCOLLADA_LIBRARY_DIR "${OPENCOLLADA_LIBRARY_DIR}" CACHE FILEPATH "OpenCOLLADA library files")
257266

@@ -268,24 +277,31 @@ IF(COLLADA_SUPPORT)
268277

269278
# Use the found OpenCOLLADAFramework as a template for all other OpenCOLLADA libraries
270279
foreach(lib ${OPENCOLLADA_LIBRARY_NAMES})
271-
string(REPLACE OpenCOLLADAFramework "${lib}" lib_path "${OpenCOLLADAFramework}")
272-
list(APPEND OPENCOLLADA_LIBRARIES "${lib_path}")
280+
# Make sure we'll handle the Windows/MSVC debug postfix convetion too.
281+
string(REPLACE OpenCOLLADAFrameworkd "${lib}" lib_path "${OpenCOLLADAFramework}")
282+
string(REPLACE OpenCOLLADAFramework "${lib}" lib_path "${lib_path}")
283+
list(APPEND OPENCOLLADA_LIBRARIES "${lib_path}")
273284
endforeach()
274285

275286
if("${PCRE_LIBRARY_DIR}" STREQUAL "")
276287
if(WIN32)
277-
find_library(pcre_library NAMES pcre PATHS ${OPENCOLLADA_LIBRARY_DIR} NO_DEFAULT_PATH)
288+
find_library(pcre_library NAMES pcre pcred PATHS ${OPENCOLLADA_LIBRARY_DIR} NO_DEFAULT_PATH)
278289
else()
279290
find_library(pcre_library NAMES pcre PATHS ${OPENCOLLADA_LIBRARY_DIR})
280291
endif()
281292
GET_FILENAME_COMPONENT(PCRE_LIBRARY_DIR ${pcre_library} PATH)
282293
else()
283-
find_library(pcre_library NAMES pcre PATHS ${PCRE_LIBRARY_DIR} NO_DEFAULT_PATH)
294+
find_library(pcre_library NAMES pcre pcred PATHS ${PCRE_LIBRARY_DIR} NO_DEFAULT_PATH)
284295
endif()
285296

286297
if (pcre_library)
287298
SET(OPENCOLLADA_LIBRARY_DIR ${OPENCOLLADA_LIBRARY_DIR} ${PCRE_LIBRARY_DIR})
288-
list(APPEND OPENCOLLADA_LIBRARIES "${pcre_library}")
299+
if (MSVC)
300+
# Add release lib regardless whether release or debug found. Debug version will be appended below.
301+
list(APPEND OPENCOLLADA_LIBRARIES "${PCRE_LIBRARY_DIR}/pcre.lib")
302+
else()
303+
list(APPEND OPENCOLLADA_LIBRARIES "${pcre_library}")
304+
endif()
289305
else()
290306
message(FATAL_ERROR "COLLADA_SUPPORT enabled, but unable to find PCRE. "
291307
"Disable COLLADA_SUPPORT or fix PCRE_LIBRARY_DIR path to proceed.")
@@ -295,7 +311,8 @@ IF(COLLADA_SUPPORT)
295311
add_debug_variants(OPENCOLLADA_LIBRARIES "${OPENCOLLADA_LIBRARIES}" d)
296312
ENDIF()
297313
ELSE()
298-
MESSAGE(FATAL_ERROR "COLLADA_SUPPORT enabled, but unable to find OpenCOLLADA. Disable COLLADA_SUPPORT or fix OpenCOLLADA paths to proceed.")
314+
message(FATAL_ERROR "COLLADA_SUPPORT enabled, but unable to find OpenCOLLADA headers. "
315+
"Disable COLLADA_SUPPORT or fix OpenCOLLADA paths to proceed.")
299316
ENDIF()
300317
ENDIF()
301318

0 commit comments

Comments
 (0)