CMakeLists
CMakeLists
###################################################################################
## CMake libtriton
cmake_minimum_required(VERSION 3.20)
set(TRITON_ROOT "${CMAKE_CURRENT_LIST_DIR}")
#Enable ctest
include(CTest)
add_custom_target(check
COMMAND ${CMAKE_COMMAND} -E env
PYTHONPATH="${CMAKE_CURRENT_BINARY_DIR}/src/libtriton" ctest --output-on-failure
DEPENDS triton
)
if(PYTHON_BINDINGS)
message(STATUS "Compiling with Python bindings")
if(PYTHON_EXECUTABLE)
# Make sure the specified python is not fully broken
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
RESULT_VARIABLE PYTHON_RESULT
OUTPUT_QUIET
)
if(NOT PYTHON_RESULT EQUAL 0)
message(FATAL_ERROR "Broken python: ${PYTHON_EXECUTABLE}")
endif()
endif()
add_test(NAME test-python
COMMAND ${PYTHON_EXECUTABLE} -m unittest discover
${triton_SOURCE_DIR}/src/testers/unittests
)
set_property(TEST test-python
PROPERTY ENVIRONMENT "PYTHONPATH=$<TARGET_FILE_DIR:triton>/"
)
else()
add_custom_target(test-python
COMMAND echo "No python test as python support is disabled"
)
endif()
# Find Z3
if(Z3_INTERFACE)
message(STATUS "Compiling with Z3 SMT solver")
find_package(Z3 REQUIRED)
message(STATUS "Z3 version: ${Z3_VERSION}")
if(TARGET z3::libz3)
link_libraries(z3::libz3)
elseif(DEFINED Z3_INCLUDE_DIRS)
include_directories(${Z3_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Unexpected Z3 package search outcome: neither target
z3::libz3 not variable Z3_INCLUDE_DIRS exists.")
endif()
set(TRITON_Z3_INTERFACE ON)
endif()
# Find bitwuzla
if(BITWUZLA_INTERFACE)
message(STATUS "Compiling with Bitwuzla SMT solver")
find_package(BITWUZLA REQUIRED)
if(TARGET Bitwuzla::bitwuzla)
link_libraries(Bitwuzla::bitwuzla)
elseif(DEFINED BITWUZLA_INCLUDE_DIRS)
include_directories(${BITWUZLA_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Unexpected Bitwuzla package search outcome: neither
target Bitwuzla::bitwuzla not variable BITWUZLA_INCLUDE_DIRS exists.")
endif()
set(TRITON_BITWUZLA_INTERFACE ON)
endif()
# Find LLVM
if(LLVM_INTERFACE)
message(STATUS "Compiling with LLVM")
if(NOT DEFINED LLVM_INCLUDE_DIRS)
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
if(LLVM_LINK_LLVM_DYLIB)
set(LLVM_LIBRARIES LLVM)
else()
set(LLVM_LIBRARIES ${LLVM_AVAILABLE_LIBS})
endif()
endif()
include_directories(${LLVM_INCLUDE_DIRS})
set(TRITON_LLVM_INTERFACE ON)
endif()
# Find Capstone
message(STATUS "Compiling with Capstone")
find_package(CAPSTONE 5 REQUIRED)
message(STATUS "CAPSTONE version: ${CAPSTONE_VERSION}")
if(TARGET capstone::capstone)
link_libraries(capstone::capstone)
elseif(DEFINED CAPSTONE_INCLUDE_DIRS)
include_directories(${CAPSTONE_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Unexpected capstone package search outcome: neither target
capstone::capstone not variable CAPSTONE_INCLUDE_DIRS exists.")
endif()
# Find boost
if(BOOST_INTERFACE)
message(STATUS "Compiling with Boost headers")
find_package(Boost 1.55.0)
if (Boost_FOUND)
include_directories("${Boost_INCLUDE_DIRS}")
set(TRITON_BOOST_INTERFACE ON)
else()
message(STATUS "Boost headers not found, compiling with wide-integer headers")
set(TRITON_BOOST_INTERFACE OFF)
endif()
else()
message(STATUS "Compiling with wide-integer headers")
set(TRITON_BOOST_INTERFACE OFF)
endif()
if(PYTHON_BINDINGS_AUTOCOMPLETE)
message(STATUS "Compiling with Python autocomplete stub")
endif()
add_subdirectory(src)
add_subdirectory(doc)