49 lines
2.1 KiB
CMake
49 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.24)
|
|
project(wikideck_randomx LANGUAGES C CXX)
|
|
|
|
include(FetchContent)
|
|
# Immutable v1.2.1 pin; never follow a branch or a moving tag.
|
|
FetchContent_Declare(randomx
|
|
GIT_REPOSITORY https://github.com/tevador/RandomX.git
|
|
GIT_TAG 102f8acf90a7649ada410de5499a7ec62e49e1da
|
|
GIT_SHALLOW FALSE
|
|
GIT_SUBMODULES ""
|
|
EXCLUDE_FROM_ALL
|
|
)
|
|
# Upstream still declares CMake 3.5 compatibility; support CMake 4 as well.
|
|
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
|
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static dependencies" FORCE)
|
|
FetchContent_MakeAvailable(randomx)
|
|
# v1.2.1 has no upstream BUILD_TESTING switch. Exclude its tools explicitly.
|
|
set_property(DIRECTORY "${randomx_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL TRUE)
|
|
foreach(tool randomx-tests randomx-codegen randomx-benchmark)
|
|
set_target_properties(${tool} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
|
endforeach()
|
|
# Enforce W^X for the upstream cache JIT as well as our VM JIT.
|
|
target_compile_definitions(randomx PRIVATE RANDOMX_FORCE_SECURE)
|
|
|
|
add_executable(wikideck-randomx randomx-engine.cpp)
|
|
target_compile_features(wikideck-randomx PRIVATE cxx_std_17)
|
|
set_target_properties(wikideck-randomx PROPERTIES CXX_EXTENSIONS OFF
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
|
foreach(config DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
|
|
set_target_properties(wikideck-randomx PROPERTIES
|
|
RUNTIME_OUTPUT_DIRECTORY_${config} "${CMAKE_BINARY_DIR}")
|
|
endforeach()
|
|
target_include_directories(wikideck-randomx PRIVATE "${randomx_SOURCE_DIR}/src")
|
|
target_link_libraries(wikideck-randomx PRIVATE randomx)
|
|
if(MSVC)
|
|
target_compile_options(wikideck-randomx PRIVATE /W4 /GS)
|
|
else()
|
|
target_compile_options(wikideck-randomx PRIVATE
|
|
-Wall -Wextra -Wpedantic -Wconversion -Wformat=2 -Wformat-security
|
|
-fstack-protector-strong)
|
|
endif()
|
|
|
|
option(WIKIDECK_RANDOMX_TESTS "Enable opt-in native known-vector test (256 MiB)" OFF)
|
|
if(WIKIDECK_RANDOMX_TESTS)
|
|
enable_testing()
|
|
add_test(NAME randomx-upstream-vector COMMAND wikideck-randomx --self-test)
|
|
set_tests_properties(randomx-upstream-vector PROPERTIES TIMEOUT 120)
|
|
endif()
|