cmake: build Lua module only if enabled
authorPetr Štetiar <ynezz@true.cz>
Mon, 4 Nov 2019 15:18:37 +0000 (16:18 +0100)
committerPetr Štetiar <ynezz@true.cz>
Thu, 14 Nov 2019 16:11:08 +0000 (17:11 +0100)
Makes the resulting lua/CMakeLists.txt file simpler.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
CMakeLists.txt
lua/CMakeLists.txt

index 5720a5f8c024e012014f3307806d93061fc2b33c..4dd75f75e67d85a00d51ebc2fc9c6c4a391f5b2c 100644 (file)
@@ -41,7 +41,9 @@ ENDIF(BUILD_STATIC)
 
 ADD_LIBRARY(ucimap STATIC ucimap.c)
 
-ADD_SUBDIRECTORY(lua)
+IF(BUILD_LUA)
+  ADD_SUBDIRECTORY(lua)
+ENDIF()
 
 IF(UNIT_TESTING)
   ENABLE_TESTING()
index b9f513a9c044464b792f28471fd0d278f47d5d25..96b122aa5029f307c5bc07f5a5f28c5fa3183c9d 100644 (file)
@@ -15,12 +15,9 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
 IF(APPLE)
   INCLUDE_DIRECTORIES(/opt/local/include)
   LINK_DIRECTORIES(/opt/local/lib)
+  SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
 ENDIF()
 
-IF(APPLE)
-       SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
-ENDIF(APPLE)
-
 IF(NOT LUAPATH)
        EXECUTE_PROCESS(
                COMMAND  lua -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,1) == \"/\" then print(k) break end end"
@@ -29,23 +26,18 @@ IF(NOT LUAPATH)
                OUTPUT_STRIP_TRAILING_WHITESPACE
        )
 
-       IF(BUILD_LUA)
-               IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR "${LUAPATH}" EQUAL "")
-                       MESSAGE(SEND_ERROR "Lua was not found on your system")
-               ENDIF()
+       IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR "${LUAPATH}" EQUAL "")
+               MESSAGE(SEND_ERROR "Lua was not found on your system")
        ENDIF()
 ENDIF()
 
-IF(BUILD_LUA)
-       ADD_LIBRARY(uci_lua MODULE uci.c)
-       SET_TARGET_PROPERTIES(uci_lua PROPERTIES
-               OUTPUT_NAME uci
-               PREFIX ""
-       )
-       TARGET_LINK_LIBRARIES(uci_lua uci dl)
-
-       INSTALL(TARGETS uci_lua
-               LIBRARY DESTINATION ${LUAPATH}
-       )
-ENDIF()
+ADD_LIBRARY(uci_lua MODULE uci.c)
+SET_TARGET_PROPERTIES(uci_lua PROPERTIES
+       OUTPUT_NAME uci
+       PREFIX ""
+)
+TARGET_LINK_LIBRARIES(uci_lua uci dl)
 
+INSTALL(TARGETS uci_lua
+       LIBRARY DESTINATION ${LUAPATH}
+)