Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add BUILD_TESTING CMake option & fix size_t push in LuaTable #6000

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,20 @@ link_directories(
${VORBISFILE_LIBRARY_DIRS}
)

list(APPEND UNITTEST_SRC_FOLDERS
src/test)
add_source_folders(UNITTEST UNITTEST_SRC_FOLDERS)
option(BUILD_TESTING "Build pioneer test executables" ON)

if (BUILD_TESTING)
list(APPEND UNITTEST_SRC_FOLDERS
src/test
)
add_source_folders(UNITTEST UNITTEST_SRC_FOLDERS)

add_executable(unittest ${UNITTEST_CXX_FILES})
target_link_libraries(unittest LINK_PRIVATE ${pioneerLibs} ${winLibs})
set_cxx_properties(unittest)
endif()

add_executable(${PROJECT_NAME} WIN32 src/main.cpp ${RESOURCES})
add_executable(unittest ${UNITTEST_CXX_FILES})
add_executable(modelcompiler src/modelcompiler.cpp)
add_executable(savegamedump
src/savegamedump.cpp
Expand Down Expand Up @@ -406,11 +414,10 @@ endif (WIN32)
add_subdirectory(src/editor)

target_link_libraries(${PROJECT_NAME} LINK_PRIVATE ${pioneerLibs} ${winLibs})
target_link_libraries(unittest LINK_PRIVATE ${pioneerLibs} ${winLibs})
target_link_libraries(modelcompiler LINK_PRIVATE ${pioneerLibs} ${winLibs})
target_link_libraries(savegamedump LINK_PRIVATE pioneer-core ${SDL2_IMAGE_LIBRARIES} ${winLibs})

set_cxx_properties(${PROJECT_NAME} unittest modelcompiler savegamedump)
set_cxx_properties(${PROJECT_NAME} modelcompiler savegamedump)

if(MSVC)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
Expand Down
9 changes: 8 additions & 1 deletion src/lua/LuaTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ LuaTable LuaTable::Set(const Key &key, const Value &value) const
template <class Value>
LuaTable &LuaTable::PushBack(Value &value)
{
pi_lua_generic_push(m_lua, Size() + 1);
pi_lua_generic_push(m_lua, static_cast<uint32_t>(Size() + 1));
pi_lua_generic_push(m_lua, value);
lua_settable(m_lua, m_index);
return *this;
Expand Down Expand Up @@ -476,4 +476,11 @@ inline void pi_lua_generic_push(lua_State *l, const LuaTable &value)
{
lua_pushvalue(l, value.GetIndex());
}

#if defined(__APPLE__)
inline void pi_lua_generic_push(lua_State *l, size_t value)
{
pi_lua_generic_push(l, static_cast<uint64_t>(value));
}
#endif
#endif