From: Petr Štetiar Date: Mon, 4 Nov 2019 15:18:37 +0000 (+0100) Subject: cmake: build Lua module only if enabled X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=be69504e3666fdde725ac67f1174736b7a328304;p=oweals%2Fuci.git cmake: build Lua module only if enabled Makes the resulting lua/CMakeLists.txt file simpler. Signed-off-by: Petr Štetiar --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5720a5f..4dd75f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/lua/CMakeLists.txt b/lua/CMakeLists.txt index b9f513a..96b122a 100644 --- a/lua/CMakeLists.txt +++ b/lua/CMakeLists.txt @@ -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} +)