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

Some build system tweaks #1879

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ef8d687
ignore .devcontainer
BobSmun Aug 29, 2024
d119241
support clangd
BobSmun Aug 29, 2024
48e6294
co-locate built artifacts during build, to allow them to be run (and …
BobSmun Aug 29, 2024
1ff0a50
use `COPY_ON_ERROR` for `file(CREATE_LINK...`, to fallback to copying…
BobSmun Sep 20, 2024
633e402
fix windows
BobSmun Sep 21, 2024
b977526
Merge remote-tracking branch 'origin/master' into build-system-tweaks
BobSmun Nov 30, 2024
d8a50c0
Merge remote-tracking branch 'origin/master' into build-system-tweaks
BobSmun Dec 1, 2024
b8ac142
* Add a unit_test target, to attach all unit tests to
BobSmun Dec 1, 2024
54484d9
Merge remote-tracking branch 'origin/master' into build-system-tweaks
BobSmun Dec 1, 2024
d40d076
Add a check for IMHEX_PATTERNS_ENABLE_UNIT_TESTS, to get build system…
BobSmun Dec 1, 2024
c930e56
Merge remote-tracking branch 'upstream/master' into build-system-tweaks
BobSmun Dec 3, 2024
39917ef
Merge remote-tracking branch 'upstream/master' into build-system-tweaks
BobSmun Dec 5, 2024
a631c20
Try address Plugin Template Test configure issue
BobSmun Dec 6, 2024
6efcc49
avoid changes being applied to EMSCRIPTEN
BobSmun Dec 6, 2024
bd5e553
pl cli required by builtin plugin
BobSmun Dec 6, 2024
b7686a9
Merge remote-tracking branch 'upstream/master' into build-system-tweaks
BobSmun Dec 7, 2024
d965ca1
pl cli integration test
BobSmun Dec 7, 2024
5370653
imhex bin not built during the unit_test target?
BobSmun Dec 7, 2024
ce26da5
add main to the unit_test build, instead of relying on the default build
BobSmun Dec 7, 2024
6ddd5f5
Build path has moved, so try update BUILD_RPATH
BobSmun Dec 8, 2024
3f50daa
bin build directory is showing up in MacOS build logs
BobSmun Dec 8, 2024
2129194
Merge remote-tracking branch 'upstream/master' into build-system-tweaks
BobSmun Dec 9, 2024
c5a68e0
Merge remote-tracking branch 'upstream/master' into build-system-tweaks
BobSmun Dec 10, 2024
a735994
Reduce impact of changes on APPLE cmake paths
BobSmun Dec 10, 2024
0138422
Merge remote-tracking branch 'upstream/master' into build-system-tweaks
BobSmun Dec 10, 2024
08d81e8
imhex on apple builds has unexpected /Config/RelWithDebInfo embedded …
BobSmun Dec 10, 2024
a46b67f
Fix builtin plugin unit test crashes:
BobSmun Dec 10, 2024
de27dc4
Add some extra helpers to windows build environment
BobSmun Dec 10, 2024
33db0da
don't require confirmation
BobSmun Dec 10, 2024
4423f55
don't require confirmation
BobSmun Dec 10, 2024
a367291
Removing unloading of plugins from plugin tests, to avoid segfault
BobSmun Dec 11, 2024
ed96c9b
re-enable hex::PluginManager::unload in the plugin tests, but also ad…
BobSmun Dec 11, 2024
623e992
* Trial windows unit tests
BobSmun Dec 11, 2024
981c958
Some copy-pasta mistakes
BobSmun Dec 11, 2024
b7cf111
Remove clangd from msys2 deps
BobSmun Dec 11, 2024
b5c9c74
Add a check to make sure ImHex-Patterns has a top level CMakeLists be…
BobSmun Dec 11, 2024
a975625
Merge branch 'master' into build-system-tweaks
BobSmun Dec 11, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.vscode/
.devcontainer/
.cache/
.idea/
.kdev4/

Expand All @@ -13,3 +15,4 @@ imgui.ini
.DS_Store
CMakeUserPresets.json
Brewfile.lock.json
compile_commands.json
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"IMHEX_PATTERNS_PULL_MASTER": "ON",
"CMAKE_INSTALL_PREFIX": "./install",
"USE_SYSTEM_CAPSTONE": "ON",
Expand Down
18 changes: 14 additions & 4 deletions cmake/build_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function(configureProject)
# Support Xcode's multi configuration paradigm by placing built artifacts into separate directories
set(IMHEX_MAIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Configs/$<CONFIG>" PARENT_SCOPE)
else()
set(IMHEX_MAIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" PARENT_SCOPE)
set(IMHEX_MAIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" PARENT_SCOPE)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably only be done on Linux as Windows and macOS use a different structure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that Windows was set up to use MinGW (effectively GCC), which would also work with these changes. In terms of file layout (e.g. executable next to shared objects next to pattern files), I anticipated that they should be compatible though I didn't test the windows build yet.

I also didn't touch the XCODE output path, which I assumed was the macOS build method. I don't have a mac to test with, but it looked like it would correctly separate out the differently configured builds.

endif()
endfunction()

Expand Down Expand Up @@ -499,16 +499,16 @@ function(downloadImHexPatternsFiles dest)

# Maybe patterns are cloned to a subdirectory
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ImHex-Patterns")
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ImHex-Patterns")
endif()

# Or a sibling directory
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ImHex-Patterns")
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ImHex-Patterns")
endif()
endif ()

if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
message(WARNING "Failed to locate ImHex-Patterns repository, some resources will be missing during install!")
elseif(XCODE)
# The Xcode build has multiple configurations, which each need a copy of these files
Expand All @@ -526,8 +526,18 @@ function(downloadImHexPatternsFiles dest)
file(GENERATE OUTPUT "${dest}/${relativePath}" INPUT "${imhex_patterns_SOURCE_DIR}/${relativePath}")
endforeach()
else()
# Make sure the IMHEX_MAIN_OUTPUT_DIRECTORY exists, as CREATE_LINK doesn't create missing intermediate directories
file(MAKE_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}")
set(PATTERNS_FOLDERS_TO_INSTALL constants encodings includes patterns magic nodes)
foreach (FOLDER ${PATTERNS_FOLDERS_TO_INSTALL})
# Make the pattern files available to ImHex binaries started from the build directory
if (NOT IMHEX_OFFLINE_BUILD)
file(COPY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION "${IMHEX_MAIN_OUTPUT_DIRECTORY}" PATTERN "**/_schema.json" EXCLUDE)
else()
# If it is an offline build, the imhex_patterns_SOURCE_DIR location is likely a git clone
# Create the directories as symbolic links, so that any changes get mirrored both ways
file(CREATE_LINK "${imhex_patterns_SOURCE_DIR}/${FOLDER}" "${IMHEX_MAIN_OUTPUT_DIRECTORY}/${FOLDER}" SYMBOLIC)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a symbolic link a good idea? Not all file systems support it.
I don't think the two-way mirroring is really necessary so a simple copy should suffice I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I have been making modifications in the PatternLibrary too, I found it useful to edit in-place next to the binary. I mostly was intending to avoid changes there getting lost.

I notice that there is a COPY_ON_ERROR flag for CREATE_LINK that I seem to have missed, which should fall back to a copy if the symbolic link is not supported.

endif()
install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION "${dest}" PATTERN "**/_schema.json" EXCLUDE)
endforeach ()
endif ()
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/ImHexPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ macro(add_imhex_plugin)
# Configure build properties
set_target_properties(${IMHEX_PLUGIN_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins"
LIBRARY_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins"
CXX_STANDARD 23
PREFIX ""
SUFFIX ${IMHEX_PLUGIN_SUFFIX}
Expand Down
2 changes: 1 addition & 1 deletion lib/libimhex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,5 @@ set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
add_dependencies(imhex_all libimhex)

install(FILES "$<TARGET_FILE:libimhex>" DESTINATION "${CMAKE_INSTALL_LIBDIR}" PERMISSIONS ${LIBRARY_PERMISSIONS})
set_target_properties(libimhex PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set_target_properties(libimhex PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY})
set_target_properties(libimhex PROPERTIES PREFIX "")
2 changes: 1 addition & 1 deletion main/forwarder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ target_link_libraries(main-forwarder PRIVATE wolv::io ${FMT_LIBRARIES})
add_dependencies(imhex_all main-forwarder)
set_target_properties(main-forwarder PROPERTIES
OUTPUT_NAME "imhex"
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../..
RUNTIME_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY}
)
4 changes: 2 additions & 2 deletions main/updater/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(updater)
project(updater)

add_executable(updater
source/main.cpp
Expand All @@ -16,5 +16,5 @@ endif()

set_target_properties(updater PROPERTIES
OUTPUT_NAME "imhex-updater"
RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY}
)