diff options
| author | sonoro1234 <sonoro@telefonica.net> | 2019-05-02 16:01:15 +0200 |
|---|---|---|
| committer | sonoro1234 <sonoro@telefonica.net> | 2019-05-02 16:01:15 +0200 |
| commit | d2d19cdaedb8096125e8a9d9c877849d9de7aa26 (patch) | |
| tree | c4e4af1dafc0fae6c40ee0a4cac1415a4e0cd9a3 | |
| parent | 9c84074c89661cd1e776eff3d4aa5329a2ac9524 (diff) | |
| download | lanes-d2d19cdaedb8096125e8a9d9c877849d9de7aa26.tar.gz lanes-d2d19cdaedb8096125e8a9d9c877849d9de7aa26.tar.bz2 lanes-d2d19cdaedb8096125e8a9d9c877849d9de7aa26.zip | |
cmake: cleaning and only link against lualib on windows (see:http://lua-users.org/wiki/BuildingModules)
| -rw-r--r-- | CMakeLists.txt | 21 | ||||
| -rw-r--r-- | dist.cmake | 130 |
2 files changed, 6 insertions, 145 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 61b7c0d..beeec4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -6,11 +6,9 @@ | |||
| 6 | 6 | ||
| 7 | PROJECT(lanes C) | 7 | PROJECT(lanes C) |
| 8 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) | 8 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
| 9 | INCLUDE(dist.cmake) | 9 | |
| 10 | 10 | ||
| 11 | FIND_PACKAGE(Lua51 REQUIRED) | 11 | FIND_PACKAGE(Lua51 REQUIRED) |
| 12 | FIND_PROGRAM(LUA NAMES lua5.1 lua51 lua) | ||
| 13 | FIND_PROGRAM(LUAC NAMES luac5.1 luac51 luac) | ||
| 14 | INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) | 12 | INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) |
| 15 | 13 | ||
| 16 | if(USE_PTHREAD) | 14 | if(USE_PTHREAD) |
| @@ -27,17 +25,6 @@ IF(CYGWIN) | |||
| 27 | ADD_DEFINITIONS(-Dpthread_yield=sched_yield) | 25 | ADD_DEFINITIONS(-Dpthread_yield=sched_yield) |
| 28 | ENDIF(CYGWIN) | 26 | ENDIF(CYGWIN) |
| 29 | 27 | ||
| 30 | #2DO - use provided bin2c | ||
| 31 | # Embed keeper.lua in text form in C (embedding bytecode is not LuaJIT2-compatible) | ||
| 32 | #ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keeper.lch | ||
| 33 | # DEPENDS src/keeper.lua | ||
| 34 | # COMMAND "${LUA}" "${CMAKE_CURRENT_SOURCE_DIR}/tools/bin2c.lua" | ||
| 35 | # "${CMAKE_CURRENT_SOURCE_DIR}/src/keeper.lua" | ||
| 36 | # "-o" "${CMAKE_CURRENT_BINARY_DIR}/keeper.lch") | ||
| 37 | #SET_SOURCE_FILES_PROPERTIES(src/lanes.c PROPERTIES OBJECT_DEPENDS | ||
| 38 | # ${CMAKE_CURRENT_BINARY_DIR}/keeper.lch) | ||
| 39 | #INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) | ||
| 40 | |||
| 41 | 28 | ||
| 42 | # Build | 29 | # Build |
| 43 | INCLUDE_DIRECTORIES(src) | 30 | INCLUDE_DIRECTORIES(src) |
| @@ -49,8 +36,12 @@ IF(UNIX AND NOT CYGWIN) | |||
| 49 | ENDIF(UNIX AND NOT CYGWIN) | 36 | ENDIF(UNIX AND NOT CYGWIN) |
| 50 | 37 | ||
| 51 | 38 | ||
| 52 | 39 | if(WIN32) | |
| 53 | TARGET_LINK_LIBRARIES(core ${LUA_LIBRARY} ${LIBS}) | 40 | TARGET_LINK_LIBRARIES(core ${LUA_LIBRARY} ${LIBS}) |
| 41 | else(WIN32) | ||
| 42 | TARGET_LINK_LIBRARIES(core ${LIBS}) | ||
| 43 | endif(WIN32) | ||
| 44 | |||
| 54 | SET_TARGET_PROPERTIES(core PROPERTIES PREFIX "") | 45 | SET_TARGET_PROPERTIES(core PROPERTIES PREFIX "") |
| 55 | 46 | ||
| 56 | # Install all files and documentation | 47 | # Install all files and documentation |
diff --git a/dist.cmake b/dist.cmake deleted file mode 100644 index 95928b2..0000000 --- a/dist.cmake +++ /dev/null | |||
| @@ -1,130 +0,0 @@ | |||
| 1 | # LuaDist CMake utility library. | ||
| 2 | # Provides variables and utility functions common to LuaDist CMake builds. | ||
| 3 | # | ||
| 4 | # Copyright (C) 2007-2010 LuaDist. | ||
| 5 | # by David Manura, Peter Drahos | ||
| 6 | # Redistribution and use of this file is allowed according to the terms of the MIT license. | ||
| 7 | # For details see the COPYRIGHT file distributed with LuaDist. | ||
| 8 | # Please note that the package source code is licensed under its own license. | ||
| 9 | |||
| 10 | # Few convinence settings | ||
| 11 | SET (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) | ||
| 12 | SET (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH}) | ||
| 13 | |||
| 14 | # Where to install module parts: | ||
| 15 | set(INSTALL_BIN bin CACHE PATH "Where to install binaries to.") | ||
| 16 | set(INSTALL_LIB lib CACHE PATH "Where to install libraries to.") | ||
| 17 | set(INSTALL_INC include CACHE PATH "Where to install headers to.") | ||
| 18 | set(INSTALL_ETC etc CACHE PATH "Where to store configuration files") | ||
| 19 | set(INSTALL_LMOD share/lua/lmod CACHE PATH "Directory to install Lua modules.") | ||
| 20 | set(INSTALL_CMOD share/lua/cmod CACHE PATH "Directory to install Lua binary modules.") | ||
| 21 | set(INSTALL_DATA share/${PROJECT_NAME} CACHE PATH "Directory the package can store documentation, tests or other data in.") | ||
| 22 | set(INSTALL_DOC ${INSTALL_DATA}/doc CACHE PATH "Recommended directory to install documentation into.") | ||
| 23 | set(INSTALL_EXAMPLE ${INSTALL_DATA}/example CACHE PATH "Recommended directory to install examples into.") | ||
| 24 | set(INSTALL_TEST ${INSTALL_DATA}/test CACHE PATH "Recommended directory to install tests into.") | ||
| 25 | set(INSTALL_FOO ${INSTALL_DATA}/etc CACHE PATH "Where to install additional files") | ||
| 26 | |||
| 27 | |||
| 28 | # In MSVC, prevent warnings that can occur when using standard libraries. | ||
| 29 | if(MSVC) | ||
| 30 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) | ||
| 31 | endif(MSVC) | ||
| 32 | |||
| 33 | # Adds Lua shared library module target `_target`. | ||
| 34 | # Additional sources to build the module are listed after `_target`. | ||
| 35 | macro(add_lua_module _target) | ||
| 36 | find_package(Lua51 REQUIRED) | ||
| 37 | include_directories(${LUA_INCLUDE_DIR}) #2DO: somehow apply only to _target? | ||
| 38 | |||
| 39 | add_library(${_target} MODULE ${ARGN}) | ||
| 40 | set_target_properties(${_target} PROPERTIES PREFIX "") | ||
| 41 | target_link_libraries(${_target} ${LUA_LIBRARY}) | ||
| 42 | |||
| 43 | IF(WIN32) | ||
| 44 | set_target_properties(${_target} PROPERTIES LINK_FLAGS "-Wl,--enable-auto-import") | ||
| 45 | ENDIF() | ||
| 46 | |||
| 47 | endmacro(add_lua_module) | ||
| 48 | |||
| 49 | # Runs Lua script `_testfile` under CTest tester. | ||
| 50 | # Optional argument `_testcurrentdir` is current working directory to run test under | ||
| 51 | # (defaults to ${CMAKE_CURRENT_BINARY_DIR}). | ||
| 52 | # Both paths, if relative, are relative to ${CMAKE_CURRENT_SOURCE_DIR}. | ||
| 53 | # Under LuaDist, set test=true in config.lua to enable testing. | ||
| 54 | macro(add_lua_test _testfile) | ||
| 55 | include(CTest) | ||
| 56 | if(BUILD_TESTING) | ||
| 57 | find_program(LUA NAMES lua lua.bat) | ||
| 58 | get_filename_component(TESTFILEABS ${_testfile} ABSOLUTE) | ||
| 59 | get_filename_component(TESTFILENAME ${_testfile} NAME) | ||
| 60 | get_filename_component(TESTFILEBASE ${_testfile} NAME_WE) | ||
| 61 | |||
| 62 | # Write wrapper script. | ||
| 63 | set(TESTWRAPPER ${CMAKE_CURRENT_BINARY_DIR}/${TESTFILENAME}) | ||
| 64 | set(TESTWRAPPERSOURCE | ||
| 65 | "package.path = '${CMAKE_CURRENT_BINARY_DIR}/?.lua\;${CMAKE_CURRENT_SOURCE_DIR}/?.lua\;' .. package.path | ||
| 66 | package.cpath = '${CMAKE_CURRENT_BINARY_DIR}/?.so\;${CMAKE_CURRENT_BINARY_DIR}/?.dll\;' .. package.cpath | ||
| 67 | return dofile '${TESTFILEABS}' | ||
| 68 | " ) | ||
| 69 | if(${ARGC} GREATER 1) | ||
| 70 | set(_testcurrentdir ${ARGV1}) | ||
| 71 | get_filename_component(TESTCURRENTDIRABS ${_testcurrentdir} ABSOLUTE) | ||
| 72 | set(TESTWRAPPERSOURCE | ||
| 73 | "require 'lfs' | ||
| 74 | lfs.chdir('${TESTCURRENTDIRABS}') | ||
| 75 | ${TESTWRAPPERSOURCE}") | ||
| 76 | endif() | ||
| 77 | FILE(WRITE ${TESTWRAPPER} ${TESTWRAPPERSOURCE}) | ||
| 78 | |||
| 79 | add_test(${TESTFILEBASE} ${LUA} ${TESTWRAPPER}) | ||
| 80 | endif(BUILD_TESTING) | ||
| 81 | |||
| 82 | # see also http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/CMakeModules/UsePythonTest.cmake | ||
| 83 | endmacro(add_lua_test) | ||
| 84 | |||
| 85 | # Converts Lua source file `_source` to binary string embedded in C source | ||
| 86 | # file `_target`. Optionally compiles Lua source to byte code (not available | ||
| 87 | # under LuaJIT2, which doesn't have a bytecode loader). Additionally, Lua | ||
| 88 | # versions of bin2c [1] and luac [2] may be passed respectively as additional | ||
| 89 | # arguments. | ||
| 90 | # | ||
| 91 | # [1] http://lua-users.org/wiki/BinToCee | ||
| 92 | # [2] http://lua-users.org/wiki/LuaCompilerInLua | ||
| 93 | function(add_lua_bin2c _target _source) | ||
| 94 | find_program(LUA NAMES lua lua.bat) | ||
| 95 | execute_process(COMMAND ${LUA} -e "string.dump(function()end)" RESULT_VARIABLE _LUA_DUMP_RESULT ERROR_QUIET) | ||
| 96 | if (NOT ${_LUA_DUMP_RESULT}) | ||
| 97 | SET(HAVE_LUA_DUMP true) | ||
| 98 | endif() | ||
| 99 | message("-- string.dump=${HAVE_LUA_DUMP}") | ||
| 100 | |||
| 101 | if (ARGV2) | ||
| 102 | get_filename_component(BIN2C ${ARGV2} ABSOLUTE) | ||
| 103 | set(BIN2C ${LUA} ${BIN2C}) | ||
| 104 | else() | ||
| 105 | find_program(BIN2C NAMES bin2c bin2c.bat) | ||
| 106 | endif() | ||
| 107 | if (HAVE_LUA_DUMP) | ||
| 108 | if (ARGV3) | ||
| 109 | get_filename_component(LUAC ${ARGV3} ABSOLUTE) | ||
| 110 | set(LUAC ${LUA} ${LUAC}) | ||
| 111 | else() | ||
| 112 | find_program(LUAC NAMES luac luac.bat) | ||
| 113 | endif() | ||
| 114 | endif (HAVE_LUA_DUMP) | ||
| 115 | message("-- bin2c=${BIN2C}") | ||
| 116 | message("-- luac=${LUAC}") | ||
| 117 | |||
| 118 | get_filename_component(SOURCEABS ${_source} ABSOLUTE) | ||
| 119 | if (HAVE_LUA_DUMP) | ||
| 120 | get_filename_component(SOURCEBASE ${_source} NAME_WE) | ||
| 121 | add_custom_command( | ||
| 122 | OUTPUT ${_target} DEPENDS ${_source} | ||
| 123 | COMMAND ${LUAC} -o ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ${SOURCEABS} | ||
| 124 | COMMAND ${BIN2C} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ">${_target}" ) | ||
| 125 | else() | ||
| 126 | add_custom_command( | ||
| 127 | OUTPUT ${_target} DEPENDS ${SOURCEABS} | ||
| 128 | COMMAND ${BIN2C} ${_source} ">${_target}" ) | ||
| 129 | endif() | ||
| 130 | endfunction(add_lua_bin2c) | ||
