Fix cmake library default build problem since moving to lib/
authorLoic Blot <loic.blot@unix-experience.fr>
Fri, 7 Apr 2017 21:56:02 +0000 (23:56 +0200)
committerLoic Blot <loic.blot@unix-experience.fr>
Fri, 7 Apr 2017 21:56:02 +0000 (23:56 +0200)
Also make Lua library check a cmake module

CMakeLists.txt
cmake/Modules/FindGMP.cmake
cmake/Modules/FindJson.cmake
cmake/Modules/FindLua.cmake [new file with mode: 0644]
lib/CMakeLists.txt [deleted file]

index aa7deaa11169b7bcbd279ff952f30d064f9dd336..4188564609960b7d9a02ec31f923a9985324b6e7 100644 (file)
@@ -186,11 +186,14 @@ if(APPLE)
        install(FILES "misc/Info.plist" DESTINATION "${BUNDLE_PATH}/Contents")
 endif()
 
+# Library pack
+find_package(GMP REQUIRED)
+find_package(Json REQUIRED)
+find_package(Lua REQUIRED)
 
 # Subdirectories
 # Be sure to add all relevant definitions above this
 
-add_subdirectory(lib)
 add_subdirectory(src)
 
 
index d584eb1e71fa45099a2059138d1664c3435495eb..64a57cfe07b11f79ca8d32cd2a391fcd9b2d852b 100644 (file)
@@ -1,6 +1,6 @@
 option(ENABLE_SYSTEM_GMP "Use GMP from system" TRUE)
 mark_as_advanced(GMP_LIBRARY GMP_INCLUDE_DIR)
-set(USE_SYSTEM_GMP FALSE PARENT_SCOPE)
+set(USE_SYSTEM_GMP FALSE)
 
 if(ENABLE_SYSTEM_GMP)
        find_library(GMP_LIBRARY NAMES libgmp.so)
@@ -9,7 +9,6 @@ if(ENABLE_SYSTEM_GMP)
        if(GMP_LIBRARY AND GMP_INCLUDE_DIR)
                message (STATUS "Using GMP provided by system.")
                set(USE_SYSTEM_GMP TRUE)
-               set(USE_SYSTEM_GMP TRUE PARENT_SCOPE)
        else()
                message (STATUS "Detecting GMP from system failed.")
        endif()
@@ -19,11 +18,9 @@ endif()
 
 if(NOT USE_SYSTEM_GMP)
        message(STATUS "Using bundled mini-gmp library.")
-       set(GMP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/gmp)
-       set(GMP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/gmp PARENT_SCOPE)
+       set(GMP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/gmp)
        set(GMP_LIBRARY gmp)
-       set(GMP_LIBRARY gmp PARENT_SCOPE)
-       add_subdirectory(gmp)
+       add_subdirectory(lib/gmp)
 endif()
 
 include(FindPackageHandleStandardArgs)
index a51a1774474414cb118656bd1e2b545c9918e33d..26339a2959d09819c051ce1d3c261d392e8b3041 100644 (file)
@@ -20,7 +20,7 @@ endif()
 
 if(NOT JSONCPP_FOUND)
        message(STATUS "Using bundled JSONCPP library.")
-       set(JSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp PARENT_SCOPE)
-       set(JSON_LIBRARY jsoncpp PARENT_SCOPE)
-       add_subdirectory(jsoncpp)
+       set(JSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/jsoncpp)
+       set(JSON_LIBRARY jsoncpp)
+       add_subdirectory(lib/jsoncpp)
 endif()
diff --git a/cmake/Modules/FindLua.cmake b/cmake/Modules/FindLua.cmake
new file mode 100644 (file)
index 0000000..be5d92d
--- /dev/null
@@ -0,0 +1,28 @@
+# Look for Lua library to use
+# This selects LuaJIT by default
+
+option(ENABLE_LUAJIT "Enable LuaJIT support" TRUE)
+set(USE_LUAJIT FALSE)
+option(REQUIRE_LUAJIT "Require LuaJIT support" FALSE)
+if(REQUIRE_LUAJIT)
+       set(ENABLE_LUAJIT TRUE)
+endif()
+if(ENABLE_LUAJIT)
+       find_package(LuaJIT)
+       if(LUAJIT_FOUND)
+               set(USE_LUAJIT TRUE)
+               message (STATUS "Using LuaJIT provided by system.")
+       elseif(REQUIRE_LUAJIT)
+               message(FATAL_ERROR "LuaJIT not found whereas REQUIRE_LUAJIT=\"TRUE\" is used.\n"
+                       "To continue, either install LuaJIT or do not use REQUIRE_LUAJIT=\"TRUE\".")
+       endif()
+else()
+       message (STATUS "LuaJIT detection disabled! (ENABLE_LUAJIT=0)")
+endif()
+
+if(NOT USE_LUAJIT)
+       message(STATUS "LuaJIT not found, using bundled Lua.")
+       set(LUA_LIBRARY lua)
+       set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/src)
+       add_subdirectory(lib/lua)
+endif()
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
deleted file mode 100644 (file)
index bc398f6..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-# LuaJIT
-option(ENABLE_LUAJIT "Enable LuaJIT support" TRUE)
-set(USE_LUAJIT FALSE PARENT_SCOPE)
-option(REQUIRE_LUAJIT "Require LuaJIT support" FALSE)
-if(REQUIRE_LUAJIT)
-       set(ENABLE_LUAJIT TRUE)
-endif()
-if(ENABLE_LUAJIT)
-       find_package(LuaJIT)
-       if(LUAJIT_FOUND)
-               set(USE_LUAJIT TRUE)
-               set(USE_LUAJIT TRUE PARENT_SCOPE)
-               message (STATUS "Using LuaJIT provided by system.")
-       elseif(REQUIRE_LUAJIT)
-               message(FATAL_ERROR "LuaJIT not found whereas REQUIRE_LUAJIT=\"TRUE\" is used.\n"
-                       "To continue, either install LuaJIT or do not use REQUIRE_LUAJIT=\"TRUE\".")
-       endif()
-else()
-       message (STATUS "LuaJIT detection disabled! (ENABLE_LUAJIT=0)")
-endif()
-
-if(NOT USE_LUAJIT)
-       message(STATUS "LuaJIT not found, using bundled Lua.")
-       set(LUA_LIBRARY lua PARENT_SCOPE)
-       set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lua/src PARENT_SCOPE)
-       add_subdirectory(lua)
-endif()
-
-find_package(GMP REQUIRED)
-find_package(Json REQUIRED)