Skip to content

Commit

Permalink
feat(cxx): update the xmake.lua with third_party
Browse files Browse the repository at this point in the history
  • Loading branch information
pplmx committed Dec 16, 2024
1 parent 26bd120 commit e926fea
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
16 changes: 11 additions & 5 deletions template/cxx/{{cookiecutter.project_slug}}/third_party/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
-- Header-only libraries configuration
-- Common configuration for third-party libraries

-- Target: httplib
target("httplib")
set_kind("headeronly")
add_includedirs("httplib")
set_kind("headeronly") -- Define it as a header-only library.
add_includedirs("httplib") -- Fallback to direct folder.
add_headerfiles("httplib/**/*.h") -- Ensure all headers are tracked for IDEs.
add_headerfiles("httplib/**/*.hpp")

-- Target: cxxopts
target("cxxopts")
set_kind("headeronly")
add_includedirs("cxxopts")
set_kind("headeronly") -- Define it as a header-only library.
add_includedirs("cxxopts") -- Default include path.
add_headerfiles("cxxopts/**/*.h") -- Track all headers.
add_headerfiles("cxxopts/**/*.hpp")
37 changes: 20 additions & 17 deletions template/cxx/{{cookiecutter.project_slug}}/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
-- Set project name and language
-- Project Configuration
set_project("{{cookiecutter.project_slug}}")
set_version("{{cookiecutter.project_version}}")
set_languages("c++{{cookiecutter.cxx_standard_version}}")

-- Include directories
add_includedirs("include")
add_requires("spdlog 1.15.0")
-- Dependencies
add_requires("spdlog 1.15.0") -- Add spdlog as a required dependency

-- Include third-party libraries
includes("third_party")

-- Add targets
-- Define Library Target
target("{{cookiecutter.package_name}}_lib")
set_targetdir("build/lib")
set_kind("static")
add_packages("spdlog")
add_files("src/*.cpp")
add_headerfiles("include/*.h")
add_deps("httplib", "cxxopts")
set_kind("static") -- Build as a static library
set_targetdir("build/lib") -- Specify output directory
add_includedirs("include") -- Include project's header files
add_files("src/*.cpp") -- Add project source files
add_headerfiles("include/*.h") -- Add project's header files
add_packages("spdlog") -- Link spdlog headers and library
add_deps("httplib", "cxxopts") -- Use httplib and cxxopts from third_party

-- Define Executable Target
target("{{cookiecutter.project_slug}}")
set_targetdir("build/bin")
set_kind("binary")
add_files("src/main.cpp")
add_deps("{{cookiecutter.package_name}}_lib")
set_kind("binary") -- Build as an executable
set_targetdir("build/bin") -- Specify output directory
add_files("src/main.cpp") -- Add main source file
add_deps("{{cookiecutter.package_name}}_lib") -- Link against the library
add_packages("spdlog") -- Include spdlog headers and library

-- Add tests
includes("tests")
-- Tests Configuration
includes("tests") -- Include the tests subdirectory

0 comments on commit e926fea

Please sign in to comment.