From edb41b5b0867fd52e497c4b1fe2b33016f47e880 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Sun, 12 Jun 2016 14:27:45 +0300 Subject: [PATCH] Rewrites FindLIBUNSHIELD using LibFindMacros Renames LIBUNSHIELD_INCLUDE_DIR -> LIBUNSHIELD_INCLUDE_DIRS, LIBUNSHIELD_LIBRARY -> LIBUNSHIELD_LIBRARIES --- CMakeLists.txt | 5 ++++ apps/wizard/CMakeLists.txt | 14 ++-------- cmake/FindLIBUNSHIELD.cmake | 53 ++++++++++++++----------------------- 3 files changed, 27 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3d20b7359..c96a18e036 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,11 @@ if (WIN32) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) endif() +if (NOT WIN32 AND BUILD_WIZARD) # windows users can just run the morrowind installer + find_package(LIBUNSHIELD REQUIRED) # required only for non win32 when building openmw-wizard + set(OPENMW_USE_UNSHIELD TRUE) +endif() + option(OPENGL_ES "enable opengl es support" FALSE ) if (OPENGL_ES) diff --git a/apps/wizard/CMakeLists.txt b/apps/wizard/CMakeLists.txt index 4be5fb2b76..dcd9444909 100644 --- a/apps/wizard/CMakeLists.txt +++ b/apps/wizard/CMakeLists.txt @@ -1,13 +1,3 @@ -if (WIN32) # windows users can just run the morrowind installer - set(OPENMW_USE_UNSHIELD FALSE) -else() - set(OPENMW_USE_UNSHIELD TRUE) - - find_package(LIBUNSHIELD REQUIRED) - if(NOT LIBUNSHIELD_FOUND) - message(FATAL_ERROR "Failed to find Unshield library") - endif(NOT LIBUNSHIELD_FOUND) -endif() set(WIZARD componentselectionpage.cpp @@ -103,7 +93,7 @@ endif() include_directories(${CMAKE_CURRENT_BINARY_DIR}) if (OPENMW_USE_UNSHIELD) - include_directories(${LIBUNSHIELD_INCLUDE_DIR}) + include_directories(${LIBUNSHIELD_INCLUDE_DIRS}) endif() add_executable(openmw-wizard @@ -132,7 +122,7 @@ else() endif() if (OPENMW_USE_UNSHIELD) - target_link_libraries(openmw-wizard ${LIBUNSHIELD_LIBRARY}) + target_link_libraries(openmw-wizard ${LIBUNSHIELD_LIBRARIES}) endif() diff --git a/cmake/FindLIBUNSHIELD.cmake b/cmake/FindLIBUNSHIELD.cmake index f0fa4cc824..285740b635 100644 --- a/cmake/FindLIBUNSHIELD.cmake +++ b/cmake/FindLIBUNSHIELD.cmake @@ -1,8 +1,8 @@ # Locate LIBUNSHIELD # This module defines -# LIBUNSHIELD_LIBRARY +# LIBUNSHIELD_LIBRARIES # LIBUNSHIELD_FOUND, if false, do not try to link to LibUnshield -# LIBUNSHIELD_INCLUDE_DIR, where to find the headers +# LIBUNSHIELD_INCLUDE_DIRS, where to find the headers # # Created by Tom Mason (wheybags) for OpenMW (http://openmw.org), based on FindMPG123.cmake # @@ -12,37 +12,24 @@ # function. Do we really need to repeat this stuff for every single # library when they all work the same? -FIND_PATH(LIBUNSHIELD_INCLUDE_DIR libunshield.h - HINTS - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - /usr/include +include(LibFindMacros) + +set(POSSIBLE_LOCATIONS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + /usr/include ) -FIND_LIBRARY(LIBUNSHIELD_LIBRARY - unshield - HINTS -# PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw - /opt/local - /opt/csw - /opt - /usr/lib +libfind_pkg_detect(LIBUNSHIELD libunshield + FIND_PATH libunshield.h + HINTS ${POSSIBLE_LOCATIONS} + FIND_LIBRARY unshield + HINTS ${POSSIBLE_LOCATIONS} ) - -IF(LIBUNSHIELD_LIBRARY AND LIBUNSHIELD_INCLUDE_DIR) - SET(LIBUNSHIELD_FOUND "YES") -ENDIF(LIBUNSHIELD_LIBRARY AND LIBUNSHIELD_INCLUDE_DIR) - +libfind_process(LIBUNSHIELD)