CMake: show error on missing LIBDIR early on
authorCampbell Barton <ideasman42@gmail.com>
Fri, 26 Feb 2016 02:42:56 +0000 (13:42 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 26 Feb 2016 02:45:24 +0000 (13:45 +1100)
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

index 5efd57c32d3f0a3d19ec0a87378674d5670d8a2f..237f3612aa508cdbd94864fe5c11fb3040359257 100644 (file)
@@ -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()