From be69504e3666fdde725ac67f1174736b7a328304 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Mon, 4 Nov 2019 16:18:37 +0100 Subject: [PATCH] cmake: build Lua module only if enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Makes the resulting lua/CMakeLists.txt file simpler. Signed-off-by: Petr Å tetiar --- CMakeLists.txt | 4 +++- lua/CMakeLists.txt | 32 ++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) 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} +) -- 2.30.2