From 941dcee0f5153c7e78b353d2b55fe812a04622ef Mon Sep 17 00:00:00 2001 From: Mikhail Paulyshka Date: Sun, 2 Nov 2014 23:43:10 +0300 Subject: [PATCH] Fix AI and VCAI CMakeLists.txt --- AI/CMakeLists.txt | 22 +++++------- AI/VCAI/CMakeLists.txt | 8 ++--- cmake_modules/FindFuzzylite.cmake | 57 +++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 cmake_modules/FindFuzzylite.cmake diff --git a/AI/CMakeLists.txt b/AI/CMakeLists.txt index f3e3f6ee2..7e3160b90 100644 --- a/AI/CMakeLists.txt +++ b/AI/CMakeLists.txt @@ -1,21 +1,17 @@ project(AI) -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8) -find_path(FUZZYLITE_INCLUDE_PATH NAMES fl/fuzzylite.h) -find_library(FUZZYLITE_LIB NAMES fuzzylite PATH_SUFFIXES dynamic) -mark_as_advanced(FUZZYLITE_INCLUDE_PATH FUZZYLITE_LIB) +find_package(Fuzzylite) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(FUZZYLITE FUZZYLITE_INCLUDE_PATH FUZZYLITE_LIB) -if (FUZZYLITE_FOUND) - set (FUZZYLITE_LIBRARIES ${FUZZYLITE_LIB}) - set (FUZZYLITE_INCLUDE_DIR ${FUZZYLITE_INCLUDE_PATH}) -endif() - -if (NOT FUZZYLITE_FOUND) +if (NOT FL_FOUND) + set(FL_BUILD_BINARY OFF CACHE BOOL "") + set(FL_BUILD_SHARED OFF CACHE BOOL "") + if(NOT MSVC) + set(FL_CPP11 ON CACHE BOOL "") + endif() add_subdirectory(FuzzyLite/fuzzylite) endif() add_subdirectory(BattleAI) add_subdirectory(StupidAI) add_subdirectory(EmptyAI) -add_subdirectory(VCAI) +add_subdirectory(VCAI) \ No newline at end of file diff --git a/AI/VCAI/CMakeLists.txt b/AI/VCAI/CMakeLists.txt index 4aec5d3c5..f5ab64342 100644 --- a/AI/VCAI/CMakeLists.txt +++ b/AI/VCAI/CMakeLists.txt @@ -1,10 +1,8 @@ project(VCAI) cmake_minimum_required(VERSION 2.6) -add_definitions(-DFL_CPP11) #TODO: Find a better way to set this macro for fuzzylite - if (FUZZYLITE_FOUND) - include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib ${FUZZYLITE_INCLUDE_DIR}) + include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib ${FL_INCLUDE_DIRS}) else() include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib ${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite) endif() @@ -19,8 +17,8 @@ set(VCAI_SRCS ) add_library(VCAI SHARED ${VCAI_SRCS}) -if (FUZZYLITE_FOUND) - target_link_libraries(VCAI ${FUZZYLITE_LIBRARIES} vcmi) +if (FL_FOUND) + target_link_libraries(VCAI ${FL_LIBRARIES} vcmi) else() target_link_libraries(VCAI fl-static vcmi) endif() diff --git a/cmake_modules/FindFuzzylite.cmake b/cmake_modules/FindFuzzylite.cmake new file mode 100644 index 000000000..69272b151 --- /dev/null +++ b/cmake_modules/FindFuzzylite.cmake @@ -0,0 +1,57 @@ +#.rst: +# FindFuzzylite +# -------- +# +# Locate Fuzzylite library +# +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# Copyright 2012 Benjamin Eikel +# Copyright 2014 Mikhail Paulyshka +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file kitware license.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_path(FL_INCLUDE_DIR + fl/fuzzylite.h + HINTS + ENV FLDIR + PATH_SUFFIXES + fl + include/fl + include +) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + +find_library(FL_LIBRARY + NAMES + fuzzylite + HINTS + ENV FLDIR + PATH_SUFFIXES + dynamic + lib + ${VC_LIB_PATH_SUFFIX} +) + +set(FL_LIBRARIES ${FL_LIBRARY}) +set(FL_INCLUDE_DIRS ${FL_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(FL + REQUIRED_VARS FL_LIBRARIES FL_INCLUDE_DIRS) + +mark_as_advanced(FL_LIBRARY FL_INCLUDE_DIR) \ No newline at end of file