🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

105 lines
3.3 KiB

# this cmake file is for compile tests.
# Not usable for your cmake app.
cmake_minimum_required(VERSION 3.5)
set(BUILD_TARGET "tinyexr")
set(SAMPLE_TARGET "test_tinyexr")
project(${BUILD_TARGET} CXX)
# options
option(TINYEXR_BUILD_SAMPLE "Build a sample" ON)
option(TINYEXR_USE_MINIZ "Use miniz" ON)
# cmake modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/sanitizers)
find_package(Sanitizers) # Address sanitizer (-DSANITIZE_ADDRESS=ON)
# Require strict C++11 mode(e.g. `-std=c++11`)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(TINYEXR_SOURCES
${PROJECT_SOURCE_DIR}/tinyexr.cc
)
if(TINYEXR_USE_MINIZ)
enable_language(C)
add_library(miniz STATIC deps/miniz/miniz.c)
target_include_directories(miniz PUBLIC deps/miniz)
set_target_properties(miniz PROPERTIES FOLDER "deps")
list(APPEND TINYEXR_EXT_LIBRARIES miniz)
endif()
add_library(${BUILD_TARGET} ${TINYEXR_SOURCES} ${TINYEXR_DEP_SOURCES})
add_sanitizers(${BUILD_TARGET})
target_compile_definitions(${BUILD_TARGET} PUBLIC TINYEXR_USE_MINIZ=0)
target_compile_definitions(${BUILD_TARGET} PUBLIC TINYEXR_USE_STB_ZLIB=1)
target_include_directories(${BUILD_TARGET} PRIVATE ${PROJECT_SOURCE_DIR})
target_link_libraries(${BUILD_TARGET} ${TINYEXR_EXT_LIBRARIES} ${CMAKE_DL_LIBS})
# Install library
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
# Install headers
install(
FILES
${PROJECT_SOURCE_DIR}/tinyexr.h
DESTINATION include)
# Install CMake config file
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
DESTINATION lib/cmake/${PROJECT_NAME})
include(CMakePackageConfigHelpers)
configure_package_config_file(
${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
DESTINATION lib/cmake/${PROJECT_NAME})
# Increase warning level for clang.
IF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_source_files_properties(${TINYEXR_SOURCES} PROPERTIES COMPILE_FLAGS "-Weverything -Werror -Wno-padded -Wno-c++98-compat-pedantic -Wno-documentation -Wno-unused-member-function")
ENDIF ()
if (TINYEXR_BUILD_SAMPLE)
set(TINYEXR_SAMPLE_SOURCES
${PROJECT_SOURCE_DIR}/test_tinyexr.cc
)
add_executable(${SAMPLE_TARGET} ${TINYEXR_SAMPLE_SOURCES})
target_link_libraries(${SAMPLE_TARGET} ${TINYEXR_EXT_LIBRARIES})
add_sanitizers(${SAMPLE_TARGET})
if (WIN32)
target_compile_definitions(${SAMPLE_TARGET} PUBLIC UNICODE)
target_compile_definitions(${SAMPLE_TARGET} PUBLIC _UNICODE)
# Set ${SAMPLE_TARGET} as a startup project for VS IDE
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${SAMPLE_TARGET})
# For easier debugging in VS IDE(cmake 3.8.0 or later required) Set working
# directory to ${BUILD_TARGET} git repo root.
if(CMAKE_VERSION VERSION_GREATER 3.8.0)
set_target_properties(${SAMPLE_TARGET}
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}")
endif()
endif(WIN32)
endif (TINYEXR_BUILD_SAMPLE)