Rgb2Hires/Rgb2Hires_PC/CMakeLists.txt

78 lines
3.1 KiB
CMake
Raw Normal View History

2021-02-01 23:35:49 +00:00
cmake_minimum_required (VERSION 3.12)
cmake_policy(SET CMP0074 NEW)
2018-10-06 22:37:44 +00:00
project (Rgb2Hires)
2021-02-01 23:35:49 +00:00
# flags not compatibles with magick++
if(WIN32)
string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string (REPLACE "/DWIN32" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif(WIN32)
2018-10-06 22:37:44 +00:00
# The version number.
set (Rgb2Hires_VERSION_MAJOR 1)
set (Rgb2Hires_VERSION_MINOR 0)
2021-02-13 16:59:57 +00:00
set(CMAKE_CXX_STANDARD 17) # required to use <filesystem>
2021-01-25 23:21:52 +00:00
set(CMAKE_VERBOSE_MAKEFILE ON)
2018-10-06 22:37:44 +00:00
2021-01-25 23:21:52 +00:00
# dependencies
2021-02-01 23:35:49 +00:00
if(WIN32)
2021-02-09 21:16:35 +00:00
# sdl2
if(NOT DEFINED ENV{SDL2_HOME})
message(FATAL_ERROR "Please set a SDL2_HOME environment variable to the root directory of SDL2")
endif()
set(SDL2_DIR $ENV{SDL2_HOME})
2021-02-01 23:35:49 +00:00
# imagemagik
if(NOT DEFINED ENV{MAGICK_HOME})
message(FATAL_ERROR "Please set a MAGICK_HOME environment variable to the root directory of ImageMagick6")
endif()
find_package(ImageMagick HINTS $ENV{MAGICK_HOME} REQUIRED COMPONENTS Magick++)
else()
find_package(ImageMagick 6.9 EXACT REQUIRED COMPONENTS Magick++ )
endif(WIN32)
2021-02-09 21:16:35 +00:00
find_package(SDL2 REQUIRED)
2021-02-01 23:35:49 +00:00
# directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/release)
2018-10-06 22:37:44 +00:00
2021-01-25 23:21:52 +00:00
# library
add_library(${PROJECT_NAME} src/Common.h
src/HiRes.cpp
src/HiRes.h
src/ImageQuantized.cpp
src/ImageQuantized.h
src/Picture.h
src/Picture.cpp
src/Tile.h
src/Tile.cpp
2021-02-09 21:16:35 +00:00
src/Display.h
src/Display.cpp
2018-10-06 22:37:44 +00:00
)
2021-01-25 23:21:52 +00:00
target_compile_definitions(${PROJECT_NAME} PRIVATE MAGICKCORE_QUANTUM_DEPTH=16 MAGICKCORE_HDRI_ENABLE=0)
2021-02-09 21:16:35 +00:00
target_include_directories(${PROJECT_NAME} PRIVATE ${ImageMagick_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS})
2021-01-25 23:21:52 +00:00
# Application Picture
add_executable(Picture src/App_Picture.cpp)
target_compile_definitions(Picture PUBLIC MAGICKCORE_QUANTUM_DEPTH=16 MAGICKCORE_HDRI_ENABLE=0)
target_include_directories(Picture PRIVATE src ${ImageMagick_INCLUDE_DIRS})
2021-02-09 21:16:35 +00:00
target_link_libraries(Picture ${ImageMagick_LIBRARIES} ${SDL2_LIBRARIES} ${PROJECT_NAME})
2021-02-01 23:35:49 +00:00
set_property(TARGET Picture PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG})
2021-01-25 23:21:52 +00:00
# Application Tile
add_executable(Tile src/App_Tile.cpp)
target_compile_definitions(Tile PUBLIC MAGICKCORE_QUANTUM_DEPTH=16 MAGICKCORE_HDRI_ENABLE=0)
target_include_directories(Tile PRIVATE src ${ImageMagick_INCLUDE_DIRS})
target_link_libraries(Tile ${ImageMagick_LIBRARIES} ${PROJECT_NAME})
2021-02-01 23:35:49 +00:00
set_property(TARGET Tile PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG})
# Windows only: copy dlls
if(WIN32)
2021-02-09 21:16:35 +00:00
set(DEBUG_EXE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/scripts/copy_im_db_dlls.bat")
set(RELEASE_EXE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/scripts/copy_im_rl_dlls.bat")
string (REPLACE "/" "\\" WIN_BIN_DIR "$<$<CONFIG:debug>:${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<CONFIG:release>:${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}>")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND "$<$<CONFIG:debug>:${DEBUG_EXE_PATH}>$<$<CONFIG:release>:${RELEASE_EXE_PATH}>" ${WIN_BIN_DIR})
endif(WIN32)