Build instructions, supported environments, and feature selection.
Overview
AsmJit is designed to be easy embeddable in any project. However, it depends on some compile-time definitions that can be used to enable or disable features to decrease the resulting binary size. A typical way of building AsmJit is to use cmake, but it's also possible to just include AsmJit source code in your project and to just build it. The easiest way to include AsmJit in your project is to just include src directory in your project and to define ASMJIT_STATIC. AsmJit can be just updated from time to time without any changes to this integration process. Do not embed AsmJit's test
files in such case as these are used exclusively for testing.
Static Builds and Embedding [¶]
These definitions can be used to enable static library build. Embed is used when AsmJit's source code is embedded directly in another project, implies static build as well.
Note
Projects that use AsmJit statically must define ASMJIT_STATIC in all compilation units that use AsmJit, otherwise AsmJit would use dynamic library imports in ASMJIT_API decorator. The recommendation is to define this macro across the whole project that uses AsmJit this way.
CMake Integration [¶]
AsmJit has a first-class CMake support. When consuming AsmJit as a cmake dependency, just use asmjit::asmjit
as a link dependency, which would instrument cmake to setup everything else, including include paths, and build flags (either defining ASMJIT_STATIC
or not, and possibly defining other AsmJit feature macros). For example considering that AsmJit was fetched to 3rdparty/asmjit
directory in your project as an external dependency, you can just use the following CMake snippet that integrates AsmJit with your own CMake project:
cmake_minimum_required(VERSION 3.30)
project(asmjit_consumer C CXX) # Both C and CXX are required.
set(CMAKE_CXX_STANDARD 17) # C++17 and never is supported.
set(ASMJIT_DIR "3rdparty/asmjit") # Location of AsmJit.
set(ASMJIT_STATIC TRUE) # Force static build.
add_subdirectory("${ASMJIT_DIR}") # This adds AsmJit as a part of your project.
add_executable(asmjit_consumer asmjit_consumer.cpp)
target_link_libraries(
asmjit_consumer asmjit::asmjit) # This adds AsmJit as a dependency to your target.
Build Type Configuration [¶]
These definitions control whether asserts are active or not. By default AsmJit would autodetect build configuration from existing pre-processor definitions, but this behavior can be overridden, for example to enable debug asserts in release configuration.
- ASMJIT_BUILD_DEBUG - Overrides build configuration to debug, asserts will be enabled in this case.
- ASMJIT_BUILD_RELEASE - Overrides build configuration to release, asserts will be disabled in this case.
Note
There is usually no need to override the build configuration. AsmJit detects the build configuration by checking whether NDEBUG
is defined and automatically defines ASMJIT_BUILD_RELEASE if configuration overrides were not used. We only recommend using build configuration overrides in special situations, like using AsmJit in release configuration with asserts enabled for whatever reason.
Build Features [¶]
AsmJit builds by default all supported features, which includes all emitters, logging, instruction validation and introspection, and JIT memory allocation. Features can be disabled at compile time by using ASMJIT_NO_...
definitions.
Note
It's not recommended to disable features if you plan to build AsmJit as a shared library that will be used by multiple projects that you don't control how AsmJit was built (for example AsmJit in a Linux distribution). The possibility to disable certain features exists mainly for customized AsmJit builds.