*/}}

CMakeLists.txt 2.2 KB

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