Improve cmake scripts

a. rename project 'plainluac' to 'luac'
b. add executable project 'lua'
c. unify cmake runtime directory to bin
This commit is contained in:
halx99 2021-03-13 18:18:40 +08:00
parent 91bfb7c8ff
commit 9aebfd4b0d
6 changed files with 35 additions and 26 deletions

View File

@ -151,7 +151,7 @@ set_target_properties(${ENGINEX_CORE_LIB}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
VERSION "${ENGINEX_VERSION}"
FOLDER "Internal"
)

View File

@ -48,7 +48,7 @@ function(setup_cocos_extension_config target_name)
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
FOLDER "Extensions"
)

View File

@ -30,6 +30,6 @@ set_target_properties(${target_name}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
FOLDER "External"
)

View File

@ -46,30 +46,39 @@ set_target_properties(${target_name}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
FOLDER "External"
)
if(WIN32 OR MACOSX)
# tool:plainluac compiling bytecode
set(target_name plainluac)
add_executable(${target_name} ${LUA_CORE} ${LUA_SRC_PATH}/luac.c)
if(${LUA_VERSION} VERSION_GREATER_EQUAL "5.4.0") # !important: traditional lua bindings solution tolua++ not support yet
target_compile_definitions(${target_name} PUBLIC LUA_COMPAT_APIINTCASTS=1)
elseif(${LUA_VERSION} VERSION_GREATER_EQUAL "5.3.0")
target_compile_definitions(${target_name}
PUBLIC LUA_COMPAT_5_1=1
PUBLIC LUA_COMPAT_5_2=1
)
elseif(${LUA_VERSION} VERSION_GREATER_EQUAL "5.2.0")
target_compile_definitions(${target_name} PUBLIC LUA_COMPAT_ALL=1)
endif()
set_target_properties(${target_name}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
FOLDER "Tools"
)
function (add_lua_bin target_name src_files)
add_executable(${target_name} ${src_files})
if(${LUA_VERSION} VERSION_GREATER_EQUAL "5.4.0") # !important: traditional lua bindings solution tolua++ not support yet
target_compile_definitions(${target_name} PUBLIC LUA_COMPAT_APIINTCASTS=1)
elseif(${LUA_VERSION} VERSION_GREATER_EQUAL "5.3.0")
target_compile_definitions(${target_name}
PUBLIC LUA_COMPAT_5_1=1
PUBLIC LUA_COMPAT_5_2=1
)
elseif(${LUA_VERSION} VERSION_GREATER_EQUAL "5.2.0")
target_compile_definitions(${target_name} PUBLIC LUA_COMPAT_ALL=1)
endif()
target_link_libraries(${target_name} plainlua)
set_target_properties(${target_name}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
FOLDER "Tools"
)
endfunction()
# tool:luac the lua bytecode compiler
add_lua_bin(luac "${LUA_SRC_PATH}/luac.c;${LUA_SRC_PATH}/ldump.c;${LUA_SRC_PATH}/lopcodes.c")
# tool:lua the lua interpreter
add_lua_bin(lua "${LUA_SRC_PATH}/lua.c")
endif()

View File

@ -47,6 +47,6 @@ set_target_properties(${target_name}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
FOLDER "External"
)

View File

@ -27,7 +27,7 @@ set_target_properties(${target_name}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
FOLDER "External"
)