*/}}

CMakeLists.txt 4.2 KB

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