*/}}

CMakeLists.txt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. cmake_minimum_required(VERSION 3.1)
  2. project(OurPaint)
  3. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
  4. find_package(lagui REQUIRED)
  5. find_package(PNG REQUIRED)
  6. find_package(LCMS2 REQUIRED)
  7. add_definitions(-w)
  8. # embed_resource("data.dat" "data.h" "DATA")
  9. function(embed_resource resource_file_name source_file_name variable_name)
  10. if(EXISTS "${source_file_name}")
  11. if("${source_file_name}" IS_NEWER_THAN "${resource_file_name}")
  12. return()
  13. endif()
  14. endif()
  15. file(READ "${resource_file_name}" hex_content HEX)
  16. string(REPEAT "[0-9a-f]" 32 pattern)
  17. string(REGEX REPLACE "(${pattern})" "\\1\n" content "${hex_content}")
  18. string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " content "${content}")
  19. string(REGEX REPLACE ", $" "" content "${content}")
  20. set(array_definition "unsigned char ${variable_name}[] =\n{\n${content}\n};")
  21. set(source "// Auto generated file.\n${array_definition}\n")
  22. file(WRITE "${source_file_name}" "${source}")
  23. endfunction()
  24. file(MAKE_DIRECTORY "BuildResources")
  25. embed_resource("Resources/splash.png" "BuildResources/data_splash.c" "DATA_SPLASH")
  26. embed_resource("Resources/splash_highdpi.png" "BuildResources/data_splash_highdpi.c" "DATA_SPLASH_HIGHDPI")
  27. include_directories(
  28. ${LAGUI_INCLUDE_DIRS_ALL}
  29. )
  30. file(GLOB_RECURSE OurPaintFiles
  31. ourpaint.c ouroperations.c ournodes.c ourtranslations.c ourshader.cpp
  32. BuildResources/data_splash.c
  33. BuildResources/data_splash_highdpi.c
  34. )
  35. add_executable(OurPaint ${OurPaintFiles})
  36. execute_process(
  37. COMMAND git rev-parse --abbrev-ref HEAD
  38. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  39. OUTPUT_VARIABLE OURPAINT_GIT_BRANCH
  40. OUTPUT_STRIP_TRAILING_WHITESPACE)
  41. execute_process(
  42. COMMAND git rev-parse --short=12 HEAD
  43. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  44. OUTPUT_VARIABLE OURPAINT_GIT_HASH
  45. OUTPUT_STRIP_TRAILING_WHITESPACE)
  46. target_compile_definitions(OurPaint PRIVATE "-DOURPAINT_GIT_BRANCH=\"${OURPAINT_GIT_BRANCH}\"")
  47. target_compile_definitions(OurPaint PRIVATE "-DOURPAINT_GIT_HASH=\"${OURPAINT_GIT_HASH}\"")
  48. target_link_libraries(OurPaint
  49. ${LAGUI_SHARED_LIBS}
  50. ${PNG_LIBRARY}
  51. ${LCMS2_LIBRARIES}
  52. )