diff --git a/template/cxx/hooks/post_gen_project.py b/template/cxx/hooks/post_gen_project.py index 4848c31..d7ca459 100644 --- a/template/cxx/hooks/post_gen_project.py +++ b/template/cxx/hooks/post_gen_project.py @@ -13,8 +13,6 @@ def remove_path_if_exists(path): cxx_build_tool = "{{cookiecutter.cxx_build_tool}}" -test_main = "tests/test_main.cpp" - cmake_root = "CMakeLists.txt" cmake_test = "tests/CMakeLists.txt" cmake_custom = "cmake" @@ -25,7 +23,6 @@ def remove_path_if_exists(path): if cxx_build_tool == "cmake": remove_path_if_exists(xmake_root) remove_path_if_exists(xmake_test) - remove_path_if_exists(test_main) elif cxx_build_tool == "xmake": remove_path_if_exists(cmake_root) remove_path_if_exists(cmake_test) diff --git a/template/cxx/{{cookiecutter.project_slug}}/tests/test_main.cpp b/template/cxx/{{cookiecutter.project_slug}}/tests/test_main.cpp deleted file mode 100644 index a529379..0000000 --- a/template/cxx/{{cookiecutter.project_slug}}/tests/test_main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "gtest/gtest.h" - -int main(int argc, char **argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/template/cxx/{{cookiecutter.project_slug}}/tests/xmake.lua b/template/cxx/{{cookiecutter.project_slug}}/tests/xmake.lua index 8e0c541..7a482f1 100644 --- a/template/cxx/{{cookiecutter.project_slug}}/tests/xmake.lua +++ b/template/cxx/{{cookiecutter.project_slug}}/tests/xmake.lua @@ -1,5 +1,5 @@ -- Add Google Test package -add_requires("gtest") +add_requires("gtest", {configs = {main = true, gmock = true}}) -- Add test target target("{{cookiecutter.project_slug}}-tests") @@ -8,3 +8,9 @@ target("{{cookiecutter.project_slug}}-tests") add_files("*.cpp") add_deps("{{cookiecutter.package_name}}_lib") add_packages("gtest") + add_links("gtest_main") + + if is_plat("windows") then + -- fixes "LINK : fatal error LNK1561: entry point must be defined" + add_ldflags("/subsystem:console") + end diff --git a/template/cxx/{{cookiecutter.project_slug}}/xmake.lua b/template/cxx/{{cookiecutter.project_slug}}/xmake.lua index 7497ae7..3c6757a 100644 --- a/template/cxx/{{cookiecutter.project_slug}}/xmake.lua +++ b/template/cxx/{{cookiecutter.project_slug}}/xmake.lua @@ -4,19 +4,19 @@ set_version("{{cookiecutter.project_version}}") set_languages("c++{{cookiecutter.cxx_standard_version}}") -- Dependencies -add_requires("spdlog 1.15.0") -- Add spdlog as a required dependency +add_requires("spdlog") -- Add spdlog as a required dependency -- Define Library Target target("{{cookiecutter.package_name}}_lib") set_kind("static") -- Build as a static library set_targetdir("build/lib") -- Specify output directory - add_includedirs("include") -- Include project's header files - add_includedirs("third_party") -- Include project's header files + add_includedirs("include", {public = true}) -- Include project's header files + add_includedirs("third_party", {public = true}) -- Include project's header files add_files("src/*.cpp") -- Add project source files - add_headerfiles("include/*.h") -- Add project's header files - add_headerfiles("include/*.hpp") -- Add project's header files - add_headerfiles("third_party/*.h") -- Add project's header files - add_headerfiles("third_party/*.hpp") -- Add project's header files + add_headerfiles("include/**/*.h") -- Add project's header files + add_headerfiles("include/**/*.hpp") -- Add project's header files + add_headerfiles("third_party/**/*.h") -- Add project's header files + add_headerfiles("third_party/**/*.hpp") -- Add project's header files add_packages("spdlog") -- Link spdlog headers and library -- Define Executable Target