You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.3 KiB
CMake

3 years ago
cmake_minimum_required(VERSION 3.0)
# project name
project(hdrplus)
# set c++ standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
6 months ago
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -static-openmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wall -static-openmp")
add_definitions(-DUSE_LCMS2)
add_definitions(-DANDROID_STL=c++_shared)
3 years ago
3 years ago
# make sure we use Release and warn otherwise
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
3 years ago
endif()
3 years ago
if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(WARNING "CMAKE_BUILD_TYPE not set to 'Release'. Performance may be terrible.")
else()
message(STATUS "Building with build type '${CMAKE_BUILD_TYPE}'")
endif()
# require OpenCV
6 months ago
find_package( OpenCV 4 REQUIRED)
3 years ago
include_directories( BEFORE ${OpenCV_INCLUDE_DIRS} )
message(STATUS "Found OpenCV ${OpenCV_INCLUDE_DIRS} ${OpenCV_LIBS}")
3 years ago
9 months ago
include_directories( BEFORE "/home/matthew/jniLibs/include/")
link_directories(/home/matthew/jniLibs/lib)
list(APPEND CMAKE_LIBRARY_PATH /home/matthew/jniLibs/lib/)
# LibRaw-cmake 0.20
6 months ago
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
SET(LIBRAW_LIBRARY "")
include_directories(${LIBRAW_INCLUDE_DIR})
link_directories(${LIBRAW_DIR})
else()
find_library(LIBRAW_LIBRARY raw)
message(STATUS "Found LIBRAW_LIBRARY to be ${LIBRAW_LIBRARY}" )
6 months ago
endif()
3 years ago
# Exiv2
6 months ago
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
include_directories(${exiv2_DIR}/include)
link_directories(${exiv2_DIR}/lib)
else()
#find_package(exiv2 REQUIRED CONFIG NAMES exiv2)
#message(STATUS "Found Exiv2 and linked")
endif()
3 years ago
# OpenMP
find_package(OpenMP REQUIRED)
3 years ago
# library
3 years ago
include_directories( include )
3 years ago
3 years ago
# all source files
set( src_files
3 years ago
src/align.cpp
src/bayer_image.cpp
src/burst.cpp
src/finish.cpp
src/hdrplus_pipeline.cpp
3 years ago
src/merge.cpp
3 years ago
src/params.cpp )
3 years ago
3 years ago
# Build runtime load dynamic shared library
# https://cmake.org/cmake/help/latest/command/add_library.html
9 months ago
add_library(${PROJECT_NAME} STATIC ${src_files} )
3 years ago
3 years ago
# and link it
# https://cmake.org/cmake/help/v3.0/command/target_link_libraries.html
3 years ago
# use public because our .h / .hpp file include opencv .h / .hpp file
3 years ago
target_link_libraries(${PROJECT_NAME} PUBLIC
${OpenCV_LIBS}
9 months ago
# ${LIBRAW_LIBRARY}
6 months ago
lcms2 raw exiv2 exiv2-xmp expat z
3 years ago
OpenMP::OpenMP_CXX )
3 years ago
# example
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin )
3 years ago
6 months ago
add_executable( hdrp
${src_files}
bin/hdrplus.cpp )
target_link_libraries( hdrp PUBLIC -fopenmp -static-openmp
${OpenCV_LIBS}
# ${LIBRAW_LIBRARY}
raw lcms2 exiv2 exiv2-xmp expat z
)
# unit test
6 months ago
if(WITH_TEST STREQUAL "ON")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/tests )
3 years ago
add_executable( test_bayer_image tests/test_bayer_image.cpp)
3 years ago
target_link_libraries( test_bayer_image
${PROJECT_NAME} )
3 years ago
3 years ago
add_executable( test_utility tests/test_utility.cpp )
3 years ago
target_link_libraries( test_utility
3 years ago
${PROJECT_NAME} )
3 years ago
add_executable( test_burst tests/test_burst.cpp )
3 years ago
target_link_libraries( test_burst
3 years ago
${PROJECT_NAME} )
3 years ago
3 years ago
add_executable( test_align tests/test_align.cpp )
3 years ago
target_link_libraries( test_align
3 years ago
${PROJECT_NAME} )
6 months ago
endif()