#!/usr/bin/cmake # Configuration to include AsmJit in a CMake-based project. If you want to # reference AsmJit as an externally compiled static library, do this: # # set(AsmJit_DIR "../ThirdParty/asmjit") # find_package(AsmJit REQUIRED CONFIG) # # target_link_libraries( # MyAwesomeProject # PRIVATE GTest::Static # PRIVATE GTest::Main # ) # # Alternatively, if you want to build AsmJit together with your project, # use the normal CMakeLists.txt with CMake's add_subdirectory() command: # # add_subdirectory( # "${PROJECT_SOURCE_DIR}/../ThirdParty/asmjit" # "${CMAKE_BINARY_DIR}/asmjit" # ) # # target_link_libraries( # MyAwesomeProject # PRIVATE AsmJit # PRIVATE AsmJitMain # ) # # ------------------------------------------------------------------------------------------------- if(NOT DEFINED NUCLEX_COMPILER_TAG) message( FATAL_ERROR "NUCLEX_COMPILER_TAG not defined! Include cplusplus.cmake before importing this package \ in order to generate a tag identifying the platform/compiler/architecture/variant!" ) endif() # ------------------------------------------------------------------------------------------------- if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/bin/${NUCLEX_COMPILER_TAG}") # TODO: Warn and link release build when compiling in debug mode # TODO: Warn and link build for older compiler version if found message( FATAL_ERROR "Directory '${CMAKE_CURRENT_LIST_DIR}/bin/${NUCLEX_COMPILER_TAG}' not found. \ Please either build and install this project before importing it via \ find_package() or use this project's main CMakeFiles.txt via add_subdirectory()!" ) endif() # ------------------------------------------------------------------------------------------------- add_library(AsmJit::Static STATIC IMPORTED) add_library(AsmJit::Main STATIC IMPORTED) # This may cause warnings on recent GCC versions (10.0.0+?) with LTO because GCC detects # that the headers used during build (residing in build/) are not the same used when # linking the library (copies resising in Include/). # # CMake doesn't run the install step during build, so the only way to get the headers # in place before building would be by copying them rather than installing them. set_target_properties( AsmJit::Static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/Include" IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" ) set_target_properties( AsmJit::Main PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/Include" IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" ) if(WIN32) set_target_properties( AsmJit::Static PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/bin/${NUCLEX_COMPILER_TAG}/asmjit.lib" ) else() set_target_properties( AsmJit::Static PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/bin/${NUCLEX_COMPILER_TAG}/libasmjit.a" ) endif() message(STATUS "Imported AsmJit targets with binaries in '${CMAKE_CURRENT_LIST_DIR}'")