[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: CMake build files for Lua 5.1.x
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Wed, 7 Oct 2009 03:13:16 -0700
On Tuesday 06, E. Wing wrote:
> On 10/1/09, Robert G. Jakabosky <bobby@sharedrealm.com> wrote:
> > Attached is a patch to add CMake build files to Lua 5.1. I have only
> > tested them on Linux, but they should work for atleast Macs & Windows
> > systems. Also
> > some of the LUA_USE_* CMake options don't do anything right now, but they
> > can
> > still be changed in src/luaconf.h
> >
> > The patch doesn't change any of the existing files in Lua, it only adds
> > about
> > 3 files. The old Makefiles will still be there.
> >
> > If you use CMake in the same folder as the source, then it will overwrite
> > some
> > of the old Makefiles.
> >
> > I would recommend this usage (for Linux type systems):
> > cd lua-5.1.4/
> > patch -p1 </tmp/lua_CMake.patch
> > mkdir build
> > cd build
> > cmake ..
> > make
> > make install
> >
> > --
>
> Hi Robert,
> I've also have a CMake build system for Lua. Would you take a look at
> it and maybe incorporate some of the ideas with yours? Mine covers a
> lot of Mac-isms (like OS X style frameworks and Universal Binaries)
> which generally people don't remember to put into their build systems.
>
> http://www.assembla.com/wiki/show/lua
I have merged the OS X frameworks code from your CMakeLists.txt file. Please
test it and report any problem or send patches.
--
Robert G. Jakabosky
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..616a562
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,229 @@
+#
+# Lua 5.1.x
+#
+cmake_minimum_required(VERSION 2.4 FATAL_ERROR)
+
+project(lua C)
+
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
+
+include(CustomMacros)
+include(CMakeDependentOption)
+
+enable_testing()
+
+#
+# Lua version
+#
+set(LUA_VERSION_MAJOR 5)
+set(LUA_VERSION_MINOR 1)
+set(LUA_VERSION_PATCH 4)
+set(LUA_VERSION
+ "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
+set(LUA_SOVERSION
+ "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
+#
+# Lua package info.
+#
+set(CPACK_PACKAGE_VERSION_MAJOR ${LUA_VERSION_MAJOR})
+set(CPACK_PACKAGE_VERSION_MINOR ${LUA_VERSION_MINOR})
+set(CPACK_PACKAGE_VERSION_PATCH ${LUA_VERSION_PATCH})
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYRIGHT")
+set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README")
+set(CPACK_PACKAGE_VENDOR "Lua.org, PUC-Rio.")
+set(CPACK_SOURCE_GENERATOR "TGZ")
+set(CPACK_SOURCE_IGNORE_FILES
+"/\\\\.;/\\\\.git.*/;~$;build/;CMakeFiles/;CMakeCache;Testing/;cmake_install;CPack;Dart;Makefile$")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME
+ "${CMAKE_PROJECT_NAME}-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
+# MUST be after CPACK_* variables.
+include(CPack)
+
+set(COMMON_CFLAGS)
+set(COMMON_LDFLAGS)
+set(LIBS)
+#
+# Detect system type
+#
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(DEFAULT_POSIX TRUE)
+ set(DEFAULT_DLOPEN ON)
+ set(DEFAULT_READLINE ON)
+ set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -Wl,-E")
+ set(USE_RPATH TRUE)
+elseif(APPLE)
+ set(DEFAULT_POSIX TRUE)
+ set(DEFAULT_DLOPEN ON)
+ # use this on Mac OS X 10.3-
+ option(LUA_USE_MACOSX "Mac OS X 10.3-" OFF)
+ set(OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX")
+ CMAKE_DEPENDENT_OPTION(WANT_FRAMEWORK
+ "Set to ON to build framework instead of dylib." ON
+ "WANT_SHARED_LIBRARY" ON
+ )
+ CMAKE_DEPENDENT_OPTION(LUA_FRAMEWORK_SYMLINKS
+ "Set to ON to create symlinks to lua & luac to CMAKE_PREFIX_PATH/bin." ON
+ "WANT_FRAMEWORK;WANT_SHARED_LIBRARY" ON
+ )
+ set(CMAKE_FRAMEWORK_INSTALL_DIR "/Library/Frameworks" CACHE STRING "Directory to install frameworks to.")
+ set(CMAKE_FRAMEWORK_INSTALL_NAME_DIR "@executable_path/../Frameworks" CACHE STRING "install_name path for framework.")
+ set(CMAKE_DYLIB_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "install_name path for dylib.")
+ set(LUA_FRAMEWORK_NAME "lua.framework")
+ set(LUA_FRAMEWORK_VERSION_NUMBER "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
+ set(LUA_FRAMEWORK_VERSIONED_EXECUTABLE_DIR "Versions/${LUA_FRAMEWORK_VERSION_NUMBER}/MacOS")
+ set(LUA_FRAMEWORK_VERSIONED_LIB_DIR "Versions/${LUA_FRAMEWORK_VERSION_NUMBER}/lib")
+ set(LUA_FRAMEWORK_CURRENT_EXECUTABLE_DIR "Versions/Current/MacOS")
+
+ # For Apple install_name, is it better to detect if Xcode vs Makefile?
+ # Xcode default=1, Makefile=0? Or detect if Framework vs. dylib,
+ # Framework=1, dylib=0?
+ option(CMAKE_BUILD_WITH_INSTALL_RPATH "Set to YES to set the rpath or install_name on build instead of install." ON)
+
+ set(LUA_SOVERSION
+ "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.0")
+elseif(CYGWIN)
+ set(DEFAULT_POSIX TRUE)
+ set(USE_RPATH TRUE)
+elseif(UNIX)
+ set(DEFAULT_POSIX TRUE)
+ set(USE_RPATH TRUE)
+elseif(WIN32)
+ set(LUA_WIN TRUE)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_BUILD_AS_DLL")
+else(APPLE)
+ set(DEFAULT_ANSI TRUE)
+endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+
+#
+# setup config options with default values.
+#
+option(WANT_SHARED_LIBRARY "Set to ON to build dynamic library." ON)
+if(WIN32)
+ set(WANT_STATIC_LIBRARY OFF)
+else(WIN32)
+ option(WANT_STATIC_LIBRARY "Set to ON to build static library." ON)
+endif(WIN32)
+
+if(USE_RPATH)
+ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "rpaths separated by semicolons.")
+ option(CMAKE_BUILD_WITH_INSTALL_RPATH "Set to YES to set the rpath or install_name on build instead of install." OFF)
+endif(USE_RPATH)
+
+if(DEFAULT_DLOPEN)
+ option(LUA_USE_DLOPEN "Enable dlopen support." ON)
+else(DEFAULT_DLOPEN)
+ option(LUA_USE_DLOPEN "Enable dlopen support." OFF)
+endif(DEFAULT_DLOPEN)
+
+if(DEFAULT_POSIX)
+ option(LUA_USE_CURSES "Enable Curses support." ON)
+ option(LUA_USE_MKSTEMP "Use mkstemp." ON)
+ option(LUA_USE_ISATTY "Enable isatty support." ON)
+ option(LUA_USE_POPEN "Enable lua_popen support." ON)
+ option(LUA_USE_ULONGJMP "Try using _longjmp/_setjmp (more efficient)" ON)
+else(DEFAULT_POSIX)
+ option(LUA_USE_CURSES "Enable Curses support." OFF)
+ option(LUA_USE_MKSTEMP "Use mkstemp." OFF)
+ option(LUA_USE_ISATTY "Enable isatty support." OFF)
+ option(LUA_USE_POPEN "Enable lua_popen support." OFF)
+ option(LUA_USE_ULONGJMP "Try using _longjmp/_setjmp (more efficient)" OFF)
+endif(DEFAULT_POSIX)
+
+if(DEFAULT_READLINE)
+ option(LUA_USE_READLINE "Enable readline support." ON)
+else(DEFAULT_READLINE)
+ option(LUA_USE_READLINE "Enable readline support." OFF)
+endif(DEFAULT_READLINE)
+
+if(DEFAULT_ANSI)
+ option(LUA_ANSI "Disable non-ansi features." ON)
+else(DEFAULT_ANSI)
+ option(LUA_ANSI "Disable non-ansi features." OFF)
+endif(DEFAULT_ANSI)
+
+option(LUA_USE_APICHECK "Enable API checks." OFF)
+
+#
+# libs & cflags
+#
+set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -lm ")
+
+# For "Mac OS X 10.3-"
+if(LUA_USE_MACOSX)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_MACOSX")
+ set(LUA_USE_DLOPEN FALSE)
+endif(LUA_USE_MACOSX)
+
+# enable options
+if(LUA_USE_DLOPEN)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_DLOPEN")
+ if(NOT APPLE)
+ set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -ldl ")
+ endif(NOT APPLE)
+endif(LUA_USE_DLOPEN)
+if(LUA_USE_MKSTEMP)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_MKSTEMP")
+endif(LUA_USE_MKSTEMP)
+if(LUA_USE_ISATTY)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_ISATTY")
+endif(LUA_USE_ISATTY)
+if(LUA_USE_POPEN)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_POPEN")
+endif(LUA_USE_POPEN)
+if(LUA_USE_ULONGJMP)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_ULONGJMP")
+endif(LUA_USE_ULONGJMP)
+if(LUA_USE_APICHECK)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_APICHECK")
+endif(LUA_USE_APICHECK)
+if(LUA_ANSI)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_ANSI")
+endif(LUA_ANSI)
+
+# readline support
+if(LUA_USE_READLINE)
+ FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h)
+ FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
+ if(READLINE_LIBRARY)
+ set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_READLINE")
+ set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -lreadline -lhistory")
+ include_directories(${READLINE_INCLUDE_DIR})
+ endif(READLINE_LIBRARY)
+endif(LUA_USE_READLINE)
+
+# curses
+if(LUA_USE_CURSES)
+ include(FindCurses)
+ if(CURSES_LIBRARY)
+ include_directories(${CURSES_INCLUDE_DIR})
+ set(LIBS ${LIBS} ${CURSES_LIBRARY})
+ endif(CURSES_LIBRARY)
+endif(LUA_USE_CURSES)
+
+#
+# standard flags to use for each build type.
+#
+if(CMAKE_COMPILER_IS_GNUCC)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -Wextra -Wshadow -W -pedantic -std=gnu99")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g")
+ set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -O1 -g")
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2 -g")
+endif(CMAKE_COMPILER_IS_GNUCC)
+
+#
+# For uninstall (needs cmake_uninstall.cmake.in in the top-level directory)
+#
+CONFIGURE_FILE(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY)
+ADD_CUSTOM_TARGET(uninstall
+ "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
+
+#
+# sub-folders
+#
+ADD_SUBDIRECTORY(src build)
+ADD_SUBDIRECTORY(test)
+
diff --git a/cmake/CustomMacros.cmake b/cmake/CustomMacros.cmake
new file mode 100644
index 0000000..9318ea4
--- /dev/null
+++ b/cmake/CustomMacros.cmake
@@ -0,0 +1,14 @@
+
+macro(add_target_properties _target _name)
+ set(_properties)
+ foreach(_prop ${ARGN})
+ set(_properties "${_properties} ${_prop}")
+ endforeach(_prop)
+ get_target_property(_old_properties ${_target} ${_name})
+ if(NOT _old_properties)
+ # in case it's NOTFOUND
+ set(_old_properties)
+ endif(NOT _old_properties)
+ set_target_properties(${_target} PROPERTIES ${_name} "${_old_properties} ${_properties}")
+endmacro(add_target_properties)
+
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..4897440
--- /dev/null
+++ b/cmake_uninstall.cmake.in
@@ -0,0 +1,18 @@
+IF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+ MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+ EXEC_PROGRAM(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ IF(NOT "${rm_retval}" STREQUAL 0)
+ MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+ ENDIF(NOT "${rm_retval}" STREQUAL 0)
+ENDFOREACH(file)
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..e88bcac
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,229 @@
+
+# Lua core source files.
+set(LUA_CORE_SRC
+ lapi.c
+ lauxlib.c
+ lbaselib.c
+ lcode.c
+ ldblib.c
+ ldebug.c
+ ldo.c
+ ldump.c
+ lfunc.c
+ lgc.c
+ linit.c
+ liolib.c
+ llex.c
+ lmathlib.c
+ lmem.c
+ loadlib.c
+ lobject.c
+ lopcodes.c
+ loslib.c
+ lparser.c
+ lstate.c
+ lstring.c
+ lstrlib.c
+ ltable.c
+ ltablib.c
+ ltm.c
+ lundump.c
+ lvm.c
+ lzio.c
+)
+set(LUA_LIB_HEADERS
+ lua.h
+ lualib.h
+ lauxlib.h
+ luaconf.h
+ ../etc/lua.hpp
+)
+set(RESOURCE_FILES
+ ../etc/strict.lua
+ ../etc/lua.ico
+)
+set(DOC_FILES
+ ../doc/lua.1
+ ../doc/luac.1
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR})
+
+#
+# Lua library.
+#
+set(LUA_LIBS)
+# lua static library.
+add_library(lua_static STATIC ${LUA_CORE_SRC})
+add_target_properties(lua_static COMPILE_FLAGS "${COMMON_CFLAGS}")
+add_target_properties(lua_static LINK_FLAGS "${LD_FLAGS} ${COMMON_LDFLAGS}")
+target_link_libraries(lua_static ${LIBS})
+set(LUA_MAIN_LIB lua_static)
+if(WANT_STATIC_LIBRARY)
+ set(LUA_LIBS lua_static)
+endif(WANT_STATIC_LIBRARY)
+# lua dynamic library
+if(WANT_SHARED_LIBRARY)
+ add_library(lua_dynamic SHARED ${LUA_CORE_SRC})
+ add_target_properties(lua_dynamic COMPILE_FLAGS "${COMMON_CFLAGS}")
+ add_target_properties(lua_dynamic LINK_FLAGS "${LD_FLAGS} ${COMMON_LDFLAGS}")
+ target_link_libraries(lua_dynamic ${LIBS})
+ set_target_properties(lua_dynamic PROPERTIES OUTPUT_NAME lua)
+
+ # link lua interpreter with dynamic library
+ set(LUA_MAIN_LIB lua_dynamic)
+ set(LUA_LIBS ${LUA_LIBS} lua_dynamic)
+endif(WANT_SHARED_LIBRARY)
+
+# set library version & soversion
+if(LUA_LIBS)
+ set_target_properties(${LUA_LIBS} PROPERTIES
+ VERSION ${LUA_VERSION}
+ SOVERSION ${LUA_SOVERSION}
+ CLEAN_DIRECT_OUTPUT 1
+ )
+endif(LUA_LIBS)
+
+if(APPLE)
+ set(INSTALL_NAME_DIR)
+ # Set Dynamic Library and Framework properties
+ if(WANT_FRAMEWORK)
+ set_target_properties(lua_dynamic PROPERTIES
+ FRAMEWORK TRUE
+ FRAMEWORK_VERSION "${LUA_FRAMEWORK_VERSION_NUMBER}"
+ PUBLIC_HEADER "${LUA_LIB_HEADERS}"
+ RESOURCE "${RESOURCE_FILES}"
+ )
+ set(INSTALL_NAME_DIR ${CMAKE_FRAMEWORK_INSTALL_NAME_DIR})
+
+ # Short Version is the "marketing version". It is the version
+ # the user sees in an information panel.
+ set(MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
+ # Bundle version is the version the OS looks at.
+ set(MACOSX_FRAMEWORK_BUNDLE_VERSION "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
+ set(MACOSX_FRAMEWORK_IDENTIFIER "org.lua.lua")
+ elseif(WANT_SHARED_LIBRARY)
+ set_target_properties(lua_dynamic PROPERTIES
+ FRAMEWORK FALSE
+ )
+ set(INSTALL_NAME_DIR ${CMAKE_DYLIB_INSTALL_NAME_DIR})
+ endif(WANT_FRAMEWORK)
+
+ if(INSTALL_NAME_DIR)
+ set_target_properties(lua_dynamic PROPERTIES
+ INSTALL_NAME_DIR ${INSTALL_NAME_DIR}
+ BUILD_WITH_INSTALL_RPATH ${CMAKE_BUILD_WITH_INSTALL_RPATH}
+ )
+ else(INSTALL_NAME_DIR)
+ # no install_name folder force BUILD_WITH_INSTALL_RPATH to OFF
+ set_property(TARGET lua_dynamic PROPERTY BUILD_WITH_INSTALL_RPATH OFF)
+ endif(INSTALL_NAME_DIR)
+
+ set(CMAKE_OSX_ARCHITECTURES ${OSX_ARCHITECTURES})
+elseif(WANT_SHARED_LIBRARY)
+ set_target_properties(lua_dynamic PROPERTIES
+ INSTALL_RPATH ${CMAKE_INSTALL_RPATH}
+ BUILD_WITH_INSTALL_RPATH ${CMAKE_BUILD_WITH_INSTALL_RPATH}
+ )
+endif(APPLE)
+
+#
+# Lua compiler
+#
+add_executable(luac luac.c print.c)
+add_target_properties(luac COMPILE_FLAGS "${COMMON_CFLAGS}")
+add_target_properties(luac LINK_FLAGS "${LD_FLAGS} ${COMMON_LDFLAGS}")
+target_link_libraries(luac lua_static ${LIBS})
+
+#
+# Lua stand-alone interpreter
+#
+add_executable(lua_binary lua.c)
+add_target_properties(lua_binary COMPILE_FLAGS "${COMMON_CFLAGS}")
+add_target_properties(lua_binary LINK_FLAGS "${LD_FLAGS} ${COMMON_LDFLAGS}")
+target_link_libraries(lua_binary ${LUA_MAIN_LIB} ${LIBS})
+# rename lub.bin to lua
+set_target_properties(lua_binary PROPERTIES OUTPUT_NAME lua)
+
+#
+# install lua/luac & library.
+#
+if(APPLE AND WANT_SHARED_LIBRARY AND WANT_FRAMEWORK)
+ # Make directory: lua.framework/Versions/5.1/MacOS
+ add_custom_command(
+ TARGET lua_dynamic
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E make_directory "${Lua_BINARY_DIR}/${LUA_FRAMEWORK_NAME}/${LUA_FRAMEWORK_VERSIONED_EXECUTABLE_DIR}"
+ COMMENT "Command line tools")
+
+ # Make directory: lua.framework/Versions/5.1/lib
+ add_custom_command(
+ TARGET lua_dynamic
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E make_directory "${Lua_BINARY_DIR}/${LUA_FRAMEWORK_NAME}/${LUA_FRAMEWORK_VERSIONED_LIB_DIR}"
+ COMMENT "Static lib")
+
+ # Copy lua to: lua.framework/Versions/5.1/MacOS/lua
+ add_custom_command(
+ TARGET lua_dynamic lua_binary
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy "${Lua_BINARY_DIR}/lua" "${Lua_BINARY_DIR}/${LUA_FRAMEWORK_NAME}/${LUA_FRAMEWORK_VERSIONED_EXECUTABLE_DIR}/lua"
+ COMMENT "Command line tools")
+
+ # Copy luac to: lua.framework/Versions/5.1/MacOS/luac
+ add_custom_command(
+ TARGET lua_dynamic luac
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy ${Lua_BINARY_DIR}/luac ${Lua_BINARY_DIR}/${LUA_FRAMEWORK_NAME}/${LUA_FRAMEWORK_VERSIONED_EXECUTABLE_DIR}/luac
+ COMMENT "Command line tools")
+
+ # Copy liblua.a to: lua.framework/Versions/5.1/lib/liblua.a
+ add_custom_command(
+ TARGET lua_dynamic lua_static
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy "${Lua_BINARY_DIR}/liblua.a" "${Lua_BINARY_DIR}/${LUA_FRAMEWORK_NAME}/${LUA_FRAMEWORK_VERSIONED_LIB_DIR}/liblua.a"
+ COMMENT "Static lib")
+
+ # Will install framework to /Library/Frameworks directory or user specified
+ install(TARGETS lua
+ FRAMEWORK DESTINATION ${CMAKE_FRAMEWORK_INSTALL_DIR}
+ )
+
+ if(LUA_FRAMEWORK_INSTALL_SYMLINKS_FOR_EXECUTABLES_TO_CMAKE_INSTALL_PREFIX_BIN_DIR)
+ install(CODE "EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E make_directory \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin\")")
+
+ # create a symbolic link for lua
+ # and add it to the install manifest
+ install(CODE "EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E create_symlink \"${CMAKE_FRAMEWORK_INSTALL_DIR}/${LUA_FRAMEWORK_NAME}/${LUA_FRAMEWORK_CURRENT_EXECUTABLE_DIR}/lua\" \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/lua\")
+ list(APPEND CMAKE_INSTALL_MANIFEST_FILES \"${CMAKE_INSTALL_PREFIX}/bin/lua\")
+ ")
+
+ # create a symbolic link for luac
+ # and add it to the install manifest
+ install(CODE "EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E create_symlink \"${CMAKE_FRAMEWORK_INSTALL_DIR}/${LUA_FRAMEWORK_NAME}/${LUA_FRAMEWORK_CURRENT_EXECUTABLE_DIR}/luac\" \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/luac\")
+ list(APPEND CMAKE_INSTALL_MANIFEST_FILES \"${CMAKE_INSTALL_PREFIX}/bin/luac\")
+ ")
+ endif(LUA_FRAMEWORK_INSTALL_SYMLINKS_FOR_EXECUTABLES_TO_CMAKE_INSTALL_PREFIX_BIN_DIR)
+
+else(APPLE AND WANT_SHARED_LIBRARY AND WANT_FRAMEWORK)
+ install(TARGETS lua_binary luac
+ RUNTIME DESTINATION bin
+ )
+ install(FILES ${DOC_FILES} DESTINATION man/man1)
+
+ if(LUA_LIBS)
+ install(TARGETS ${LUA_LIBS}
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ )
+ install(FILES ${LUA_LIB_HEADERS} DESTINATION include)
+ endif(LUA_LIBS)
+
+endif(APPLE AND WANT_SHARED_LIBRARY AND WANT_FRAMEWORK)
+