projects/uci: lua: use built in pkg-config support for alternatives
[project/uci.git] / lua / CMakeLists.txt
index a532fc1..b9f513a 100644 (file)
@@ -4,10 +4,20 @@ PROJECT(uci C)
 
 SET(CMAKE_INSTALL_PREFIX /)
 
-ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -I..)
+IF(NOT LUA_CFLAGS)
+       INCLUDE(FindPkgConfig)
+       pkg_search_module(LUA lua5.1 lua-5.1)
+ENDIF()
+
+ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -I.. ${LUA_CFLAGS})
 LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
 IF(APPLE)
+  INCLUDE_DIRECTORIES(/opt/local/include)
+  LINK_DIRECTORIES(/opt/local/lib)
+ENDIF()
+
+IF(APPLE)
        SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
 ENDIF(APPLE)
 
@@ -20,7 +30,7 @@ IF(NOT LUAPATH)
        )
 
        IF(BUILD_LUA)
-               IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR ${LUAPATH} EQUAL "")
+               IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR "${LUAPATH}" EQUAL "")
                        MESSAGE(SEND_ERROR "Lua was not found on your system")
                ENDIF()
        ENDIF()