*/}}

CMakeLists.txt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. cmake_minimum_required(VERSION 3.1)
  2. project(OurPaint)
  3. IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  4. SET(CMAKE_INSTALL_PREFIX $ENV{HOME}/OurPaint CACHE PATH "Where to install Our Paint" FORCE)
  5. ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  6. set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".")
  7. include (InstallRequiredSystemLibraries)
  8. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
  9. find_package(lagui REQUIRED)
  10. find_package(PNG REQUIRED)
  11. find_package(LCMS2 REQUIRED)
  12. add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
  13. add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
  14. add_definitions(-w)
  15. # embed_resource("data.dat" "data.h" "DATA")
  16. function(embed_resource resource_file_name source_file_name variable_name)
  17. if(EXISTS "${source_file_name}")
  18. if("${source_file_name}" IS_NEWER_THAN "${resource_file_name}")
  19. return()
  20. endif()
  21. endif()
  22. file(READ "${resource_file_name}" hex_content HEX)
  23. string(REPEAT "[0-9a-f]" 32 pattern)
  24. string(REGEX REPLACE "(${pattern})" "\\1\n" content "${hex_content}")
  25. string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " content "${content}")
  26. string(REGEX REPLACE ", $" "" content "${content}")
  27. set(array_definition "unsigned char ${variable_name}[] =\n{\n${content}\n};")
  28. set(source "// Auto generated file.\n${array_definition}\n")
  29. file(WRITE "${source_file_name}" "${source}")
  30. endfunction()
  31. file(MAKE_DIRECTORY "BuildResources")
  32. embed_resource("Resources/splash.png" "BuildResources/data_splash.c" "DATA_SPLASH")
  33. embed_resource("Resources/splash_highdpi.png" "BuildResources/data_splash_highdpi.c" "DATA_SPLASH_HIGHDPI")
  34. include_directories(
  35. ${LAGUI_INCLUDE_DIRS_ALL}
  36. )
  37. file(GLOB_RECURSE OurPaintFiles
  38. ourpaint.c ouroperations.c ournodes.c ourtranslations.c ourshader.cpp
  39. BuildResources/data_splash.c
  40. BuildResources/data_splash_highdpi.c
  41. )
  42. add_executable(OurPaint ${OurPaintFiles})
  43. execute_process(
  44. COMMAND git rev-parse --abbrev-ref HEAD
  45. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  46. OUTPUT_VARIABLE OURPAINT_GIT_BRANCH
  47. OUTPUT_STRIP_TRAILING_WHITESPACE)
  48. execute_process(
  49. COMMAND git rev-parse --short=12 HEAD
  50. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  51. OUTPUT_VARIABLE OURPAINT_GIT_HASH
  52. OUTPUT_STRIP_TRAILING_WHITESPACE)
  53. target_compile_definitions(OurPaint PRIVATE "-DOURPAINT_GIT_BRANCH=\"${OURPAINT_GIT_BRANCH}\"")
  54. target_compile_definitions(OurPaint PRIVATE "-DOURPAINT_GIT_HASH=\"${OURPAINT_GIT_HASH}\"")
  55. target_link_libraries(OurPaint
  56. ${LAGUI_SHARED_LIBS}
  57. ${PNG_LIBRARY}
  58. ${LCMS2_LIBRARIES}
  59. )
  60. SET(INSTALL_EXTRAS
  61. README.md default_brushes.udf COPYING COPYING_CC_BY_NC)
  62. SET(LAGUI_FONT_CUSTOM_PATH $ENV{HOME}/.local/share/fonts/lagui CACHE STRING "Where to find lagui fonts")
  63. if (NOT DEFINED ${LAGUI_FONT_CUSTOM_PATH})
  64. set(LAGUI_FONT_CUSTOM_PATH $ENV{HOME}/.local/share/fonts/lagui)
  65. endif()
  66. set(INSTALL_PATH_BIN ".")
  67. if(${CMAKE_VERSION} VERSION_LESS "3.21")
  68. install(TARGETS OurPaint DESTINATION ${INSTALL_PATH_BIN})
  69. else()
  70. install(TARGETS OurPaint RUNTIME_DEPENDENCY_SET runtime_deps DESTINATION ${INSTALL_PATH_BIN})
  71. LIST(APPEND pre_exclude_regexes "api-ms-.*")
  72. LIST(APPEND pre_exclude_regexes "ext-ms-.*")
  73. LIST(APPEND post_exclude_regexes ".*WINDOWS[\\/]system32.*")
  74. LIST(APPEND post_exclude_regexes "^/lib" "^/usr" "^/bin")
  75. install(RUNTIME_DEPENDENCY_SET runtime_deps
  76. PRE_EXCLUDE_REGEXES ${pre_exclude_regexes}
  77. POST_EXCLUDE_REGEXES ${post_exclude_regexes}
  78. DESTINATION ${INSTALL_PATH_BIN}
  79. )
  80. endif()
  81. install(DIRECTORY "${LAGUI_FONT_CUSTOM_PATH}/" DESTINATION ${INSTALL_PATH_BIN}/fonts PATTERN "*.*")
  82. install(FILES ${INSTALL_EXTRAS} DESTINATION ${INSTALL_PATH_BIN})