Skip to content

Commit

Permalink
Simplify cmake install command of lua modules (Mudlet#3168)
Browse files Browse the repository at this point in the history
* Simplify cmake install command of lua modules

This has multiple positive effects. For one it gets rid of the
comparison of found to expected number of files. This was usually forgotten
to adapt. Second it simplifies the logic of the actual install calls. It
now uses cmake buildin functionality instead of homegrown loops.

* Remove unused LCF_DIR variable
  • Loading branch information
keneanung authored Oct 18, 2019
1 parent 2737c0a commit b643200
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 65 deletions.
40 changes: 0 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,46 +220,6 @@ if(APPLE)
endif()
endif()

file(GLOB_RECURSE lua_files RELATIVE "${CMAKE_HOME_DIRECTORY}/src/mudlet-lua/lua/" "${CMAKE_HOME_DIRECTORY}/src/mudlet-lua/lua/*.lua")
list(LENGTH lua_files lua_file_count)
if(lua_file_count EQUAL 28)
message(STATUS "Found Mudlet & Geyser lua files")
else()
message(WARNING "Found ${lua_file_count} Mudlet & Geyser lua files but 28 were expected:")
foreach(lua_file ${lua_files})
message(STATUS " ${lua_file}")
endforeach(lua_file)
endif()

file(GLOB_RECURSE lua_test_files RELATIVE "${CMAKE_HOME_DIRECTORY}/src/mudlet-lua/tests/" "${CMAKE_HOME_DIRECTORY}/src/mudlet-lua/tests/*.lua")
list(LENGTH lua_test_files lua_test_file_count)
if(lua_test_file_count EQUAL 5)
message(STATUS "Found Mudlet Lua test files")
else()
message(WARNING "Found ${lua_test_file_count} Mudlet Lua test files but 5 were expected:")
foreach(lua_test_file ${lua_test_files})
message(STATUS " ${lua_test_file}")
endforeach()
endif()

if(EXISTS "${CMAKE_HOME_DIRECTORY}/3rdparty/lcf/lcf-scm-1.rockspec")
file(GLOB_RECURSE lcf_files RELATIVE "${CMAKE_HOME_DIRECTORY}/3rdparty/" "${CMAKE_HOME_DIRECTORY}/3rdparty/lcf/*")
list(REMOVE_ITEM lcf_files "lcf/.git")
list(LENGTH lcf_files lcf_file_count)
if(lcf_file_count EQUAL 275)
message(STATUS "Found Lua Code Formatter files")
else()
message(WARNING "Found ${lcf_file_count} Lua Code Formatter files but 275 were expected:")
foreach(lcf_file ${lcf_files})
message(STATUS " ${lcf_file}")
endforeach(lcf_file)
endif()
elseif()
message(FATAL_ERROR "Cannot locate lua code formatter submodule source code, build abandoned!")
endif()



find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
Expand Down
43 changes: 18 additions & 25 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ endif()

if(UNIX)
set(LUA_DEFAULT_DIR "${CMAKE_INSTALL_PREFIX}/share/mudlet/lua")
set(LCF_DIR "${CMAKE_INSTALL_PREFIX}/share/mudlet/lua/lcf")
endif(UNIX)

# Define a preprocessor symbol with the default fallback location from which
Expand Down Expand Up @@ -400,30 +399,24 @@ target_compile_options(mudlet
if(UNIX)
# CMAKE_INSTALL_PREFIX is automagically set on Unix to DESTDIR environment
# variable and is prefixed onto relative DESTINATION values
foreach(lua_file ${lua_files})
get_filename_component(lua_file_name ${lua_file} NAME)
get_filename_component(lua_file_path ${lua_file} DIRECTORY)
install(FILES "${CMAKE_HOME_DIRECTORY}/src/mudlet-lua/lua/${lua_file}"
DESTINATION "share/mudlet/lua/${lua_file_path}"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
CONFIGURATIONS Debug Release)
endforeach()
foreach(lua_test_file ${lua_test_files})
get_filename_component(lua_test_file_name ${lua_test_file} NAME)
get_filename_component(lua_test_file_path ${lua_test_file} DIRECTORY)
install(FILES "${CMAKE_HOME_DIRECTORY}/src/mudlet-lua/tests/${lua_test_file}"
DESTINATION "share/mudlet/tests/${lua_test_file_path}"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
CONFIGURATIONS Debug Release)
endforeach()
foreach(lcf_file ${lcf_files})
get_filename_component(lcf_file_name ${lcf_file} NAME)
get_filename_component(lcf_file_path ${lcf_file} DIRECTORY)
install(FILES "${CMAKE_HOME_DIRECTORY}/3rdparty/${lcf_file}"
DESTINATION "share/mudlet/lua/${lcf_file_path}"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
CONFIGURATIONS Debug Release)
endforeach(lcf_file)
install(
DIRECTORY "mudlet-lua/lua"
DESTINATION "share/mudlet"
FILES_MATCHING PATTERN "*.lua"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
install(
DIRECTORY "mudlet-lua/tests"
DESTINATION "share/mudlet"
FILES_MATCHING PATTERN "*.lua"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
install(
DIRECTORY "../3rdparty/lcf"
DESTINATION "share/mudlet/lua"
PATTERN ".git" EXCLUDE
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
install(TARGETS mudlet
RUNTIME
DESTINATION "bin"
Expand Down

0 comments on commit b643200

Please sign in to comment.