mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-17 06:37:43 -05:00
Apply clang-format and cmake-format and add style check workflow (#171)
* apply clang-format and cmake-format and add style check workflow * add declare package definition * add additional public methods and rename internals * change development verison tag to 1.0.0 * rename internal method * rename public method * rename test var * update copyright and fix comment * typo * run fix-format * fix test function names
This commit is contained in:
@@ -13,20 +13,16 @@ CPMAddPackage(
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
|
||||
if (lua_ADDED)
|
||||
if(lua_ADDED)
|
||||
# lua has no CMakeLists, so we create our own target
|
||||
|
||||
FILE(GLOB lua_sources ${lua_SOURCE_DIR}/*.c)
|
||||
file(GLOB lua_sources ${lua_SOURCE_DIR}/*.c)
|
||||
list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c")
|
||||
add_library(lua STATIC ${lua_sources})
|
||||
|
||||
target_include_directories(lua
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${lua_SOURCE_DIR}>
|
||||
)
|
||||
target_include_directories(lua PUBLIC $<BUILD_INTERFACE:${lua_SOURCE_DIR}>)
|
||||
endif()
|
||||
|
||||
|
||||
CPMAddPackage(
|
||||
NAME sol2
|
||||
URL https://github.com/ThePhD/sol2/archive/v3.0.2.zip
|
||||
@@ -34,7 +30,7 @@ CPMAddPackage(
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
|
||||
if (sol2_ADDED)
|
||||
if(sol2_ADDED)
|
||||
add_library(sol2 INTERFACE IMPORTED)
|
||||
target_include_directories(sol2 INTERFACE ${sol2_SOURCE_DIR}/include)
|
||||
target_link_libraries(sol2 INTERFACE lua)
|
||||
@@ -43,6 +39,5 @@ endif()
|
||||
# ---- Executable ----
|
||||
|
||||
add_executable(CPMSol2Example "main.cpp")
|
||||
set_target_properties(CPMSol2Example PROPERTIES CXX_STANDARD 17)
|
||||
set_target_properties(CPMSol2Example PROPERTIES CXX_STANDARD 17)
|
||||
target_link_libraries(CPMSol2Example sol2)
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#include <sol/sol.hpp>
|
||||
#include <cassert>
|
||||
#include <sol/sol.hpp>
|
||||
|
||||
struct vars {
|
||||
int boop = 0;
|
||||
int boop = 0;
|
||||
};
|
||||
|
||||
int main() {
|
||||
sol::state lua;
|
||||
lua.open_libraries( sol::lib::base );
|
||||
lua.new_usertype<vars>("vars", "boop", &vars::boop);
|
||||
lua.script("beep = vars.new()\n"
|
||||
"beep.boop = 1\n"
|
||||
"print('beep boop')");
|
||||
assert(lua.get<vars>("beep").boop == 1);
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
lua.new_usertype<vars>("vars", "boop", &vars::boop);
|
||||
lua.script(
|
||||
"beep = vars.new()\n"
|
||||
"beep.boop = 1\n"
|
||||
"print('beep boop')");
|
||||
assert(lua.get<vars>("beep").boop == 1);
|
||||
}
|
||||
Reference in New Issue
Block a user