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 all 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
64 changes: 62 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug \
-DIMHEX_ENABLE_UNIT_TESTS=ON \
-DIMHEX_ENABLE_PLUGIN_TESTS=ON \
-DIMHEX_PATTERNS_ENABLE_UNIT_TESTS=OFF \
-DLIBPL_ENABLE_TESTS=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="-fuse-ld=lld -fsanitize=address,leak,undefined -fno-sanitize-recover=all --coverage" \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld -fsanitize=address,leak,undefined -fno-sanitize-recover=all --coverage" \
-DIMHEX_OFFLINE_BUILD=ON \
..
make -j4 unit_tests
make -j4 unit_tests main

- name: 🧪 Perform plcli Integration Tests
run: |
cd lib/external/pattern_language
python tests/integration/integration.py ../../../build/imhex --pl
python tests/integration/integration.py ../../../build/bin/imhex --pl

- name: 🧪 Perform Unit Tests
run: |
Expand All @@ -82,6 +84,64 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage_report.xml

tests-win:
name: 🧪 Unit Tests (windows)
runs-on: windows-2022
defaults:
run:
shell: msys2 {0}
env:
CCACHE_DIR: "${{ github.workspace }}/.ccache"
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: 📜 Setup ccache
uses: hendrikmuhs/ccache-action@v1
id: cache-ccache
with:
key: ${{ runner.os }}-ccache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-ccache
max-size: 1G

- name: 🟦 Install msys2
uses: msys2/setup-msys2@v2
with:
msystem: mingw64

- name: ⬇️ Install dependencies
run: |
set -x
dist/get_deps_msys2.sh

# Windows cmake build
- name: 🛠️ Build
run: |
set -x
mkdir -p build
cd build

cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DIMHEX_USE_DEFAULT_BUILD_SETTINGS=ON \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DUSE_SYSTEM_CAPSTONE=ON \
-DIMHEX_ENABLE_UNIT_TESTS=ON \
-DIMHEX_ENABLE_PLUGIN_TESTS=ON \
-DIMHEX_PATTERNS_ENABLE_UNIT_TESTS=OFF \
-DLIBPL_ENABLE_TESTS=OFF \
-DIMHEX_OFFLINE_BUILD=ON \
..
ninja -j4 unit_tests

- name: 🧪 Perform Unit Tests
run: |
cd build
ctest --output-on-failure

langs:
name: 🧪 Langs
runs-on: ubuntu-22.04
Expand Down
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 @@ -14,3 +16,4 @@ imgui.ini
.DS_Store
CMakeUserPresets.json
Brewfile.lock.json
compile_commands.json
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ option(IMHEX_ENABLE_UNIT_TESTS "Enable building unit tests"
option(IMHEX_ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers" OFF)
option(IMHEX_COMPRESS_DEBUG_INFO "Compress debug information" ON )

# if enabled, add a unit_test custom target for all the unit tests to be registered against
if (IMHEX_ENABLE_UNIT_TESTS)
# should be first instance, but check anyway for consistency
if(NOT TARGET unit_tests)
enable_testing()
add_custom_target(unit_tests)
endif()
endif()

set(IMHEX_BASE_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_MODULE_PATH "${IMHEX_BASE_FOLDER}/cmake/modules")

Expand Down Expand Up @@ -69,14 +78,16 @@ addBundledLibraries()

add_subdirectory(lib/libimhex)
add_subdirectory(main)
addPluginDirectories()

# Add unit tests
if (IMHEX_ENABLE_UNIT_TESTS)
enable_testing()
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif ()

# Do this after adding the tests, so that the plugins_test runner binary has
# a chance of being created before being referenced by plugin tests
addPluginDirectories()

# Configure more resources that will be added to the install package
generatePDBs()
generateSDKDirectory()
Expand Down
7 changes: 6 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
"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",
"IMHEX_ENABLE_UNIT_TESTS": "ON",
"IMHEX_ENABLE_PLUGIN_TESTS": "ON",
"LIBPL_ENABLE_TESTS": "ON",
"IMHEX_PATTERNS_ENABLE_UNIT_TESTS": "ON",
"IMHEX_USE_DEFAULT_BUILD_SETTINGS": "ON"
}
},
Expand Down Expand Up @@ -52,7 +57,7 @@
"name": "x86_64",
"description": "x86_64 build",
"configurePreset": "x86_64",
"targets": [ "imhex_all" ]
"targets": [ "imhex_all", "unit_tests" ]
}
],
"testPresets": [
Expand Down
28 changes: 22 additions & 6 deletions cmake/build_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ function(configureProject)
if (XCODE)
# 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()
elseif(EMSCRIPTEN OR APPLE)
set(IMHEX_MAIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" PARENT_SCOPE)
else()
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 @@ -500,16 +502,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 @@ -527,10 +529,24 @@ 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}" COPY_ON_ERROR SYMBOLIC)
endif()
install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION "${dest}" PATTERN "**/_schema.json" EXCLUDE)
endforeach ()
# Register ImHex-Patterns, if manually cloned
if(IMHEX_OFFLINE_BUILD AND EXISTS ${imhex_patterns_SOURCE_DIR}/CMakeLists.txt AND IMHEX_PATTERNS_ENABLE_UNIT_TESTS)
add_subdirectory(${imhex_patterns_SOURCE_DIR})
endif()
endif ()

endfunction()
Expand Down Expand Up @@ -742,8 +758,8 @@ macro(addBundledLibraries)
set_target_properties(
libpl
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
RUNTIME_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY}
LIBRARY_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY}
)
endif()
enableUnityBuild(libpl)
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/ImHexPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ macro(add_imhex_plugin)
# Set rpath of plugin libraries to the plugins folder
if (APPLE)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES BUILD_RPATH "@executable_path/../Frameworks;@executable_path/plugins")
else()
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins")
endif()

# Setup a romfs for the plugin
Expand Down Expand Up @@ -124,8 +126,6 @@ macro(add_imhex_plugin)

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt AND IMHEX_ENABLE_UNIT_TESTS AND IMHEX_ENABLE_PLUGIN_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_NAME}_tests)
target_compile_definitions(${IMHEX_PLUGIN_NAME}_tests PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}-tests")
endif()
endmacro()

Expand Down
3 changes: 2 additions & 1 deletion dist/get_deps_msys2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ pacboy -S --needed --noconfirm \
bzip2:p \
xz:p \
zstd:p \
lz4:p
lz4:p \
gdb:p
7 changes: 6 additions & 1 deletion lib/libimhex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,10 @@ 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})
if(IMHEX_EXTERNAL_PLUGIN_BUILD)
set_target_properties(libimhex PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
else()
set_target_properties(libimhex PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY})
set_target_properties(libimhex PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY})
endif()
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 @@ -11,7 +11,7 @@ add_dependencies(main updater)
if (APPLE)
set(OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}/Contents/MacOS")
else ()
set(OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}")
endif()

set_target_properties(updater PROPERTIES
Expand Down
10 changes: 7 additions & 3 deletions plugins/builtin/source/content/views/view_hex_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace hex::plugin::builtin {

class PopupSelect : public ViewHexEditor::Popup {
public:

PopupSelect(u64 address, size_t size): m_region({address, size}) {}

void draw(ViewHexEditor *editor) override {
Expand Down Expand Up @@ -584,8 +584,6 @@ namespace hex::plugin::builtin {
EventProviderChanged::unsubscribe(this);
EventProviderOpened::unsubscribe(this);
EventHighlightingChanged::unsubscribe(this);

ContentRegistry::Settings::write<int>("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.bytes_per_row", m_hexEditor.getBytesPerRow());
}

void ViewHexEditor::drawPopup() {
Expand Down Expand Up @@ -655,10 +653,16 @@ namespace hex::plugin::builtin {
}

void ViewHexEditor::drawContent() {
const auto prevBytesPerRow = m_hexEditor.getBytesPerRow();

m_hexEditor.setProvider(ImHexApi::Provider::get());

m_hexEditor.draw();

if(prevBytesPerRow != m_hexEditor.getBytesPerRow()) {
ContentRegistry::Settings::write<int>("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.bytes_per_row", m_hexEditor.getBytesPerRow());
}

this->drawPopup();
}

Expand Down
13 changes: 10 additions & 3 deletions plugins/builtin/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ set(AVAILABLE_TESTS
Providers/InvalidResize
)

add_library(${PROJECT_NAME} SHARED
add_library(${PROJECT_NAME} OBJECT
source/main.cpp
)

# link into plugins_test, so that test registration works
target_link_libraries(plugins_test PUBLIC ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/plugins/builtin/include)

target_link_libraries(${PROJECT_NAME} PRIVATE libimhex)

foreach (test IN LISTS AVAILABLE_TESTS)
add_test(NAME "Plugin_${IMHEX_PLUGIN_NAME}/${test}" COMMAND $<TARGET_FILE:plugins_test> "${test}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endforeach ()
add_test(NAME "Plugin_${IMHEX_PLUGIN_NAME}/${test}" COMMAND $<TARGET_FILE:plugins_test> "${test}" WORKING_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY})
endforeach ()

# remember to add dependency on the plugin itself to the unit_test target, so that it also gets built
add_dependencies(unit_tests ${IMHEX_PLUGIN_NAME})
target_compile_definitions(${PROJECT_NAME} PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}-tests")
8 changes: 7 additions & 1 deletion plugins/script_loader/support/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
project(c_api)

add_library(c_api OBJECT
if (IMHEX_STATIC_LINK_PLUGINS)
set(C_API_LIBRARY_TYPE STATIC)
else()
set(C_API_LIBRARY_TYPE OBJECT)
endif()

add_library(c_api ${C_API_LIBRARY_TYPE}
source/script_api/v1/bookmarks.cpp
source/script_api/v1/logger.cpp
source/script_api/v1/mem.cpp
Expand Down
4 changes: 0 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
project(unit_tests)

add_custom_target(unit_tests DEPENDS imhex_all helpers algorithms plugins)

add_subdirectory(common)
target_compile_definitions(tests_common PUBLIC IMHEX_PROJECT_NAME="${PROJECT_NAME}")

add_subdirectory(helpers)
add_subdirectory(algorithms)
Expand Down
4 changes: 2 additions & 2 deletions tests/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ add_executable(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME} PRIVATE include)
target_link_libraries(${PROJECT_NAME} PRIVATE libimhex tests_common ${FMT_LIBRARIES})

set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY})

foreach (test IN LISTS AVAILABLE_TESTS)
add_test(NAME "${TEST_CATEGORY}/${test}" COMMAND ${PROJECT_NAME} "${test}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME "${TEST_CATEGORY}/${test}" COMMAND ${PROJECT_NAME} "${test}" WORKING_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY})
endforeach ()
add_dependencies(unit_tests ${PROJECT_NAME})
4 changes: 4 additions & 0 deletions tests/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ project(tests_common)
add_library(tests_common STATIC
source/main.cpp
)

target_link_libraries(tests_common PUBLIC libimhex ${FMT_LIBRARIES} libwolv)
add_dependencies(unit_tests ${PROJECT_NAME})

target_compile_definitions(tests_common PUBLIC IMHEX_PROJECT_NAME="${PROJECT_NAME}")
Loading
Loading