From 0b1398930737ec4475706922809d1b88c18ac8fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 Feb 2016 13:42:56 +1100 Subject: CMake: show error on missing LIBDIR early on Previously CMake would show many messages about missing libs before checking for a missing LIBDIR. Now show the error immediately and exit. Also allow for custom LIBDIR on OSX. --- CMakeLists.txt | 58 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5efd57c32d3..237f3612aa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1328,7 +1328,10 @@ elseif(WIN32) set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc12) endif() else() - message(STATUS using LIBDIR ${LIBDIR}) + message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") + endif() + if(NOT EXISTS "${LIBDIR}/") + message(FATAL_ERROR "Windows requires pre-compiled libs at: '${LIBDIR}'") endif() # Add each of our libraries to our cmake_prefix_path so find_package() could work @@ -1648,18 +1651,25 @@ elseif(WIN32) " WITH_MINGW64) - if(WITH_MINGW64) - message(STATUS "Compiling for 64 bit with MinGW-w64.") - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64) - else() - message(STATUS "Compiling for 32 bit with MinGW-w32.") - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32) - - if(WITH_RAYOPTIMIZATION) - message(WARNING "MinGW-w32 is known to be unstable with 'WITH_RAYOPTIMIZATION' option enabled.") + if(NOT DEFINED LIBDIR) + if(WITH_MINGW64) + message(STATUS "Compiling for 64 bit with MinGW-w64.") + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64) + else() + message(STATUS "Compiling for 32 bit with MinGW-w32.") + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32) + + if(WITH_RAYOPTIMIZATION) + message(WARNING "MinGW-w32 is known to be unstable with 'WITH_RAYOPTIMIZATION' option enabled.") + endif() endif() + else() + message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") endif() - + if(NOT EXISTS "${LIBDIR}/") + message(FATAL_ERROR "Windows requires pre-compiled libs at: '${LIBDIR}'") + endif() + list(APPEND PLATFORM_LINKLIBS -lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi -ldbghelp) if(WITH_INPUT_IME) @@ -1934,16 +1944,22 @@ elseif(APPLE) set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/7/8/9 endif() - if(WITH_LIBS10.5) - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal) - else() - if(CMAKE_OSX_ARCHITECTURES MATCHES i386) - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386) + if(NOT DEFINED LIBDIR) + if(WITH_LIBS10.5) + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal) else() - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc) + if(CMAKE_OSX_ARCHITECTURES MATCHES i386) + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386) + else() + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc) + endif() endif() + else() + message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") + endif() + if(NOT EXISTS "${LIBDIR}/") + message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'") endif() - if(WITH_OPENAL) find_package(OpenAL) @@ -2294,12 +2310,6 @@ endif() #----------------------------------------------------------------------------- # Common. -if(APPLE OR WIN32) - if(NOT EXISTS "${LIBDIR}/") - message(FATAL_ERROR "Apple and Windows require pre-compiled libs at: '${LIBDIR}'") - endif() -endif() - if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM) message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON") endif() -- cgit v1.2.3