#!/usr/bin/cmake cmake_minimum_required (VERSION 3.18) # ------------------------------------------------------------------------------------------------- project( Blend2D VERSION 0.18 DESCRIPTION "High quality vector graphics rendering library" ) include("../../BuildSystem/cmake/cplusplus.cmake") # Blend2D uses AsmJit to build its rasterizing code at runtime if(NOT (TARGET AsmJit)) add_subdirectory(${PROJECT_SOURCE_DIR}/../asmjit ${CMAKE_BINARY_DIR}/asmjit) endif() # ------------------------------------------------------------------------------------------------- if(NOT EXISTS ${PROJECT_SOURCE_DIR}/downloads/blend2d-beta18.tar.xz) message(STATUS "Downloading Blend2D sources") file( DOWNLOAD https://blend2d.com/download/blend2d-beta18.tar.xz ${PROJECT_SOURCE_DIR}/downloads/blend2d-beta18.tar.xz SHOW_PROGRESS EXPECTED_HASH SHA256=e0162d249d9db066ef89f9ede2589936113c1f0eeaf3f2260d9396abdb221dc6 STATUS DOWNLOAD_STATUS ) if(NOT DOWNLOAD_STATUS EQUAL 0) file(REMOVE ${PROJECT_SOURCE_DIR}/downloads/blend2d-beta18.tar.xz) message(FATAL_ERROR "Download failed, stopping build (error ${DOWNLOAD_STATUS})") endif() endif() # ------------------------------------------------------------------------------------------------- if(NOT EXISTS ${PROJECT_SOURCE_DIR}/build) message(STATUS "Extracting Blend2D sources") file( ARCHIVE_EXTRACT INPUT ${PROJECT_SOURCE_DIR}/downloads/blend2d-beta18.tar.xz DESTINATION ${CMAKE_BINARY_DIR}/extract ) file( RENAME ${CMAKE_BINARY_DIR}/extract/blend2d ${PROJECT_SOURCE_DIR}/build ) endif() configure_file( "${PROJECT_SOURCE_DIR}/api-build_p.h" "${PROJECT_SOURCE_DIR}/build/src/blend2d/api-build_p.h" COPYONLY ) # ------------------------------------------------------------------------------------------------- set( sourceFiles "build/src/blend2d/pipeline/jit/compoppart.cpp" "build/src/blend2d/pipeline/jit/fetchgradientpart.cpp" "build/src/blend2d/pipeline/jit/fetchpart.cpp" "build/src/blend2d/pipeline/jit/fetchpatternpart.cpp" "build/src/blend2d/pipeline/jit/fetchpixelptrpart.cpp" "build/src/blend2d/pipeline/jit/fetchsolidpart.cpp" "build/src/blend2d/pipeline/jit/fetchutils.cpp" "build/src/blend2d/pipeline/jit/fillpart.cpp" "build/src/blend2d/pipeline/jit/pipecompiler.cpp" "build/src/blend2d/pipeline/jit/pipegencore.cpp" "build/src/blend2d/pipeline/jit/pipegenruntime.cpp" "build/src/blend2d/pipeline/jit/pipepart.cpp" "build/src/blend2d/pipeline/pipedefs.cpp" "build/src/blend2d/pipeline/piperuntime.cpp" "build/src/blend2d/pipeline/reference/fixedpiperuntime.cpp" "build/src/blend2d/api-globals.cpp" "build/src/blend2d/api-nocxx.cpp" "build/src/blend2d/array.cpp" "build/src/blend2d/bitset.cpp" "build/src/blend2d/codec/bmpcodec.cpp" "build/src/blend2d/codec/jpegcodec.cpp" "build/src/blend2d/codec/jpeghuffman.cpp" "build/src/blend2d/codec/jpegops.cpp" "build/src/blend2d/codec/jpegops_sse2.cpp" "build/src/blend2d/codec/pngcodec.cpp" "build/src/blend2d/codec/pngops.cpp" "build/src/blend2d/codec/pngops_sse2.cpp" "build/src/blend2d/compop.cpp" "build/src/blend2d/compression/checksum.cpp" "build/src/blend2d/compression/deflatedecoder.cpp" "build/src/blend2d/compression/deflateencoder.cpp" "build/src/blend2d/context.cpp" "build/src/blend2d/filesystem.cpp" "build/src/blend2d/font.cpp" "build/src/blend2d/fontmanager.cpp" "build/src/blend2d/format.cpp" "build/src/blend2d/geometry.cpp" "build/src/blend2d/pixelconverter.cpp" "build/src/blend2d/pixelconverter_avx2.cpp" "build/src/blend2d/pixelconverter_sse2.cpp" "build/src/blend2d/pixelconverter_ssse3.cpp" "build/src/blend2d/pixelops/funcs.cpp" "build/src/blend2d/pixelops/interpolation.cpp" "build/src/blend2d/pixelops/interpolation_avx2.cpp" "build/src/blend2d/pixelops/interpolation_sse2.cpp" "build/src/blend2d/pixelops/scalar.cpp" "build/src/blend2d/random.cpp" "build/src/blend2d/raster/analyticrasterizer.cpp" "build/src/blend2d/raster/rastercontext.cpp" "build/src/blend2d/raster/rastercontextops.cpp" "build/src/blend2d/raster/renderfetchdata.cpp" "build/src/blend2d/raster/rendertargetinfo.cpp" "build/src/blend2d/raster/workdata.cpp" "build/src/blend2d/raster/workermanager.cpp" "build/src/blend2d/raster/workerproc.cpp" "build/src/blend2d/raster/workersynchronization.cpp" "build/src/blend2d/rgba.cpp" "build/src/blend2d/runtime.cpp" "build/src/blend2d/string.cpp" "build/src/blend2d/support/algorithm.cpp" "build/src/blend2d/support/arenaallocator.cpp" "build/src/blend2d/support/arenahashmap.cpp" "build/src/blend2d/support/arenalist.cpp" "build/src/blend2d/support/arenatree.cpp" "build/src/blend2d/support/bitops.cpp" "build/src/blend2d/support/intops.cpp" "build/src/blend2d/support/memops.cpp" "build/src/blend2d/support/ptrops.cpp" "build/src/blend2d/support/scopedallocator.cpp" "build/src/blend2d/tables.cpp" "build/src/blend2d/threading/futex.cpp" "build/src/blend2d/threading/thread.cpp" "build/src/blend2d/threading/threadpool.cpp" "build/src/blend2d/threading/uniqueidgenerator.cpp" "build/src/blend2d/trace.cpp" "build/src/blend2d/unicode.cpp" "build/src/blend2d/var.cpp" "build/src/blend2d/zeroallocator.cpp" "build/src/blend2d/glyphbuffer.cpp" "build/src/blend2d/gradient.cpp" "build/src/blend2d/image.cpp" "build/src/blend2d/imagecodec.cpp" "build/src/blend2d/imagescale.cpp" "build/src/blend2d/math.cpp" "build/src/blend2d/matrix.cpp" "build/src/blend2d/matrix_avx.cpp" "build/src/blend2d/matrix_sse2.cpp" "build/src/blend2d/object.cpp" "build/src/blend2d/opentype/otcff.cpp" "build/src/blend2d/opentype/otcmap.cpp" "build/src/blend2d/opentype/otcore.cpp" "build/src/blend2d/opentype/otface.cpp" "build/src/blend2d/opentype/otglyf.cpp" "build/src/blend2d/opentype/otglyf_avx2.cpp" "build/src/blend2d/opentype/otkern.cpp" "build/src/blend2d/opentype/otlayout.cpp" "build/src/blend2d/opentype/otmetrics.cpp" "build/src/blend2d/opentype/otname.cpp" "build/src/blend2d/path.cpp" "build/src/blend2d/pathstroke.cpp" "build/src/blend2d/pattern.cpp" ) set( linuxSourceFiles "build/src/blend2d/opentype/otglyf_sse4_2.cpp" ) file( GLOB_RECURSE headerFiles CONFIGURE_DEPENDS "build/common/*.h" "build/src/*.h" ) # ------------------------------------------------------------------------------------------------- add_library(Blend2D SHARED) add_library(Blend2D::Dynamic ALIAS Blend2D) target_compile_definitions( Blend2D PRIVATE BL_BUILD_OPT_SSE4_2 ) target_include_directories( Blend2D INTERFACE "build/src/" ) target_sources( Blend2D PUBLIC ${headerFiles} PRIVATE ${sourceFiles} ) if(NOT WIN32) target_sources( Blend2D PRIVATE ${linuxSourceFiles} ) endif() # Link against PThreads and the AsmJit library Blend2D uses target_link_libraries( Blend2D PRIVATE AsmJit::Static ) # Make sure the build fails if the shared library is missing any symbols # (otherwise this would only be detected when building the final executable) if(NOT WIN32) # Supposedly, there is a portable way to specify these but since it's # CMake, the documentation doesn't give an example and is wrong as well: # https://cmake.org/cmake/help/latest/command/add_link_options.html message(STATUS "Using symbolic link to catch unresolved symbols") # Detect unresolved symbols in shared object set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs") # Prevent replacement on shared object syms set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Bsymbolic") endif() #set_target_properties(Blend2D PROPERTIES PREFIX "") set_target_properties(Blend2D PROPERTIES OUTPUT_NAME "blend2d") # ------------------------------------------------------------------------------------------------- #install( # DIRECTORY build/include/blend2d # DESTINATION ${PROJECT_SOURCE_DIR}/Include #) install( TARGETS Blend2D ARCHIVE DESTINATION ${PROJECT_SOURCE_DIR}/bin/${NUCLEX_COMPILER_TAG} LIBRARY DESTINATION ${PROJECT_SOURCE_DIR}/bin/${NUCLEX_COMPILER_TAG} RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/bin/${NUCLEX_COMPILER_TAG} ) # Install .pdb files on Windows platforms. # # CMake forgets installing .pdb files for debug builds. These are needed by # Microsoft compilers when debugging to associate machine code locations to # source files and line numbers. install_debug_symbols(Blend2D) # ------------------------------------------------------------------------------------------------- file( WRITE "${PROJECT_SOURCE_DIR}/Blend2DConfig.cmake" "#!/usr/bin/cmake # Configuration to include Blend2D in a CMake-based project. If you want to # reference Blend2D as an externally compiled static library, do this: # # set(Blend2D_DIR \"../ThirdParty/blend2d\") # find_package(Blend2D REQUIRED CONFIG) # # target_link_libraries( # MyAwesomeProject # PRIVATE GTest::Static # PRIVATE GTest::Main # ) # # Alternatively, if you want to build Blend2D together with your project, # use the normal CMakeLists.txt with CMake's add_subdirectory() command: # # add_subdirectory( # \"\${PROJECT_SOURCE_DIR}/../ThirdParty/blend2d\" # \"\${CMAKE_BINARY_DIR}/blend2d\" # ) # # target_link_libraries( # MyAwesomeProject # PRIVATE Blend2D # PRIVATE Blend2DMain # ) # # ------------------------------------------------------------------------------------------------- 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(Blend2D::Static STATIC IMPORTED) add_library(Blend2D::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( Blend2D::Static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"\${CMAKE_CURRENT_LIST_DIR}/Include\" IMPORTED_LINK_INTERFACE_LANGUAGES \"CXX\" ) set_target_properties( Blend2D::Main PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"\${CMAKE_CURRENT_LIST_DIR}/Include\" IMPORTED_LINK_INTERFACE_LANGUAGES \"CXX\" ) if(WIN32) set_target_properties( Blend2D::Static PROPERTIES IMPORTED_LOCATION \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}/blend2d.lib\" ) set_target_properties( Blend2D::Main PROPERTIES IMPORTED_LOCATION \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}/blend2d_main.lib\" ) else() set_target_properties( Blend2D::Static PROPERTIES IMPORTED_LOCATION \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}/libblend2d.a\" ) set_target_properties( Blend2D::Main PROPERTIES IMPORTED_LOCATION \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}/libblend2d_main.a\" ) endif() message(STATUS \"Imported Blend2D targets with binaries in '\${CMAKE_CURRENT_LIST_DIR}'\")" ) # -------------------------------------------------------------------------------------------------