Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.
Open
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
12 changes: 9 additions & 3 deletions cmake_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
local p = premake
local tree = p.tree
local project = p.project
local workspace = p.workspace
local config = p.config
local cmake = p.modules.cmake

Expand Down Expand Up @@ -98,6 +99,9 @@ function m.generate(prj)
for _, includedir in ipairs(cfg.includedirs) do
_x(1, '$<$<CONFIG:%s>:%s>', cmake.cfgname(cfg), includedir)
end
for _, includedir in ipairs(cfg.externalincludedirs) do
_x(1, '$<$<CONFIG:%s>:%s>', cmake.cfgname(cfg), includedir)
end
_p(')')

-- defines
Expand Down Expand Up @@ -181,11 +185,13 @@ function m.generate(prj)
standard["C++14"] = 14
standard["C++17"] = 17
standard["C++20"] = 20
standard["C++23"] = 23
standard["gnu++98"] = 98
standard["gnu++11"] = 11
standard["gnu++14"] = 14
standard["gnu++17"] = 17
standard["gnu++20"] = 20
standard["gnu++23"] = 23

local extentions = iif(cfg.cppdialect:find('^gnu') == nil, 'NO', 'YES')
local pic = iif(cfg.pic == 'On', 'True', 'False')
Expand All @@ -211,22 +217,22 @@ function m.generate(prj)
-- test locally in the project folder first (this is the most likely location)
local testname = path.join(cfg.project.basedir, pch)
if os.isfile(testname) then
pch = project.getrelative(cfg.project, testname)
pch = workspace.getrelative(cfg.workspace, testname)
found = true
else
-- else scan in all include dirs.
for _, incdir in ipairs(cfg.includedirs) do
testname = path.join(incdir, pch)
if os.isfile(testname) then
pch = project.getrelative(cfg.project, testname)
pch = workspace.getrelative(cfg.workspace, testname)
found = true
break
end
end
end

if not found then
pch = project.getrelative(cfg.project, path.getabsolute(pch))
pch = workspace.getrelative(cfg.workspace, path.getabsolute(pch))
end

_p('if(CMAKE_BUILD_TYPE STREQUAL %s)', cmake.cfgname(cfg))
Expand Down