Skip to content

Commit 1e7c2ed

Browse files
committed
Workaround for command dependencies (PRE_BUILD)
1 parent 362c790 commit 1e7c2ed

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

build/write_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def ParseIncludeFile(srcInclude, dstInclude, rev):
2525
for line in sF:
2626
dF.write(line.replace("{{GIT_REVISION}}", rev))
2727

28-
def main(srcDir, srcInclude, dstInclude):
28+
def main(srcDir, srcInclude, dstInclude, versionPath):
2929
# Get rev
3030
rev = GetRevision(srcDir)
3131
branch = GetBranchName(srcDir)
@@ -41,7 +41,7 @@ def main(srcDir, srcInclude, dstInclude):
4141
"#define BUILD_DATE \"{0}\"".format(datetime.datetime.now())
4242
)
4343

44-
with open("{}/src/Version.hpp".format(srcDir), "w+") as f:
44+
with open("{}".format(versionPath), "w+") as f:
4545
f.write("\n".join(lines))
4646

4747
if __name__ == "__main__":

src/CMakeLists.txt

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
include(AMXConfig)
22
include(AddSAMPPlugin)
33

4+
# Create dummy target that does nothing
5+
add_custom_target(spdloglib_deps)
6+
47
set(SOURCE_FILES
58
Logprintf.cpp
69
Natives.cpp
@@ -29,11 +32,35 @@ target_compile_definitions(
2932
BOOST_ALL_NO_LIB
3033
)
3134

35+
# SPDLog Include file handling
36+
set(SPDLOG_VERSION_FILE "${SAMP_LOG_BIN_ROOT}/Version.hpp")
37+
set(SPDLOG_INCLUDE_RAW "${SAMP_LOG_ROOT}/include/a_spdlog.inc.in")
38+
set(SPDLOG_INCLUDE_SRC "${SAMP_LOG_BIN_ROOT}/a_spdlog.inc")
39+
set(SPDLOG_INCLUDE_DST "${SAMP_LOG_BIN_OUT_DIR}/include/a_spdlog.inc")
40+
41+
# Parse include file to out
42+
add_custom_command(
43+
TARGET spdloglib_deps POST_BUILD
44+
COMMAND ${PYTHON_EXECUTABLE} ${SAMP_LOG_ROOT}/build/write_version.py ${SAMP_LOG_ROOT} ${SPDLOG_INCLUDE_RAW} ${SPDLOG_INCLUDE_SRC} ${SPDLOG_VERSION_FILE}
45+
COMMENT "Generate version file")
46+
47+
# Copy to output directorry (we also can write the file
48+
# directly but then we need to create also the directory tree)
49+
add_custom_command(
50+
TARGET spdloglib_deps POST_BUILD
51+
COMMAND ${CMAKE_COMMAND} -E copy
52+
${SPDLOG_INCLUDE_SRC}
53+
${SPDLOG_INCLUDE_DST}
54+
COMMENT "Copy Pawno include file")
55+
56+
# Deps
57+
add_dependencies(spdloglib spdloglib_deps)
58+
3259
# Link
3360
target_link_libraries(spdloglib boost-lib-filesystem sampsdk spdlog)
3461

3562
# Includes
36-
target_include_directories(spdloglib PRIVATE ${BOOST_LIB_PATH})
63+
target_include_directories(spdloglib PRIVATE ${BOOST_LIB_PATH} ${SAMP_LOG_BIN_ROOT})
3764

3865
# Properties
3966
set_target_properties(spdloglib PROPERTIES OUTPUT_NAME "spdlog")
@@ -45,21 +72,3 @@ set_target_properties(spdloglib
4572
LIBRARY_OUTPUT_DIRECTORY "${SAMP_LOG_BIN_OUT_DIR}"
4673
RUNTIME_OUTPUT_DIRECTORY "${SAMP_LOG_BIN_OUT_DIR}"
4774
)
48-
49-
# SPDLog Include file handling
50-
set(SPDLOG_INCLUDE_RAW "${SAMP_LOG_ROOT}/include/a_spdlog.inc.in")
51-
set(SPDLOG_INCLUDE_SRC "${SAMP_LOG_BIN_ROOT}/a_spdlog.inc")
52-
set(SPDLOG_INCLUDE_DST "${SAMP_LOG_BIN_OUT_DIR}/include/a_spdlog.inc")
53-
54-
# Parse include file to out
55-
add_custom_command(
56-
TARGET spdloglib PRE_BUILD
57-
COMMAND ${PYTHON_EXECUTABLE} ${SAMP_LOG_ROOT}/build/write_version.py ${SAMP_LOG_ROOT} ${SPDLOG_INCLUDE_RAW} ${SPDLOG_INCLUDE_SRC})
58-
59-
# Copy to output directorry (we also can write the file
60-
# directly but then we need to create also the directory tree)
61-
add_custom_command(
62-
TARGET spdloglib POST_BUILD
63-
COMMAND ${CMAKE_COMMAND} -E copy
64-
${SPDLOG_INCLUDE_SRC}
65-
${SPDLOG_INCLUDE_DST})

src/Natives.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "Logger.hpp"
66
#include "Natives.hpp"
7-
#include "Version.hpp"
7+
#include <Version.hpp>
88

99
#include <iostream>
1010
#include <memory>

src/Plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// SAMP SDK & Log handler
1010
#include "plugin.h"
1111
#include "Logprintf.hpp"
12-
#include "Version.hpp"
12+
#include <Version.hpp>
1313

1414
// SPDLog
1515
#include <spdlog/spdlog.h>

0 commit comments

Comments
 (0)