Skip to content

Commit

Permalink
cmake: option to not generate gimp palettes
Browse files Browse the repository at this point in the history
  • Loading branch information
cthbleachbit committed Sep 24, 2021
1 parent 83253af commit 4612c70
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${warnings} -fPIC")

option(BUILD_TESTS "Build library test harness" OFF)
option(BUILD_PAMENIM "Build Pamenim" ON)
option(BUILD_GIMP_GPL "Generate and install palette data for GIMP" ON)

set(MINEMAP_PALETTE_DIR ${CMAKE_INSTALL_DATADIR}/minemap/palettes CACHE STRING "Directory to place minemap palette GIFs relative to prefix")
set(GIMP_PALETTE_DIR ${CMAKE_INSTALL_DATADIR}/gimp/2.0/palettes CACHE STRING "Directory to place GIMP palettes")
if (BUILD_GIMP_GPL)
set(GIMP_PALETTE_DIR ${CMAKE_INSTALL_DATADIR}/gimp/2.0/palettes CACHE STRING "Directory to place GIMP palettes")
endif()
add_compile_definitions(MINEMAP_PALETTE_DIR=\"${CMAKE_INSTALL_PREFIX}/${MINEMAP_PALETTE_DIR}\")

# External
Expand Down
37 changes: 21 additions & 16 deletions misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ target_link_libraries(gen_color_map PUBLIC ${ImageMagick_LIBRARIES})
target_include_directories(gen_color_map PUBLIC ${ImageMagick_INCLUDE_DIRS})
target_compile_options(gen_color_map PUBLIC ${ImageMagick_CFLAGS_OTHER})

add_executable(gen_gimp_palette gen_gimp_palette.cpp)
target_link_libraries(gen_gimp_palette PUBLIC ${ImageMagick_LIBRARIES})
target_include_directories(gen_gimp_palette PUBLIC ${ImageMagick_INCLUDE_DIRS})
target_compile_options(gen_gimp_palette PUBLIC ${ImageMagick_CFLAGS_OTHER})
if (BUILD_GIMP_GPL)
add_executable(gen_gimp_palette gen_gimp_palette.cpp)
endif ()

set(MC_VERSIONS
1.8
Expand All @@ -15,20 +14,26 @@ set(MC_VERSIONS
1.17
)

foreach(MC_VERSION IN LISTS MC_VERSIONS)
set(PALETTE_FILE_NAME "rgba-${MC_VERSION}.txt" )
foreach (MC_VERSION IN LISTS MC_VERSIONS)
set(PALETTE_FILE_NAME "rgba-${MC_VERSION}.txt")
set(GIF_FILE_OUTPUT "rgba-${MC_VERSION}.gif")
set(GIMP_FILE_PREFIX "Minecraft${MC_VERSION}")
add_custom_target("gen_gif_palettes_${MC_VERSION}" ALL
DEPENDS gen_color_map
COMMAND $<TARGET_FILE:gen_color_map> "${CMAKE_CURRENT_SOURCE_DIR}/${PALETTE_FILE_NAME}" "${GIF_FILE_OUTPUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target("gen_gimp_palettes_${MC_VERSION}" ALL
DEPENDS gen_gimp_palette
COMMAND $<TARGET_FILE:gen_gimp_palette> "${CMAKE_CURRENT_SOURCE_DIR}/${PALETTE_FILE_NAME}" "${GIMP_FILE_PREFIX}"
DEPENDS gen_color_map
COMMAND $<TARGET_FILE:gen_color_map> "${CMAKE_CURRENT_SOURCE_DIR}/${PALETTE_FILE_NAME}" "${GIF_FILE_OUTPUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${GIF_FILE_OUTPUT}" DESTINATION ${MINEMAP_PALETTE_DIR})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${GIMP_FILE_PREFIX}.gpl" DESTINATION ${GIMP_PALETTE_DIR})
endforeach()
endforeach ()

if (BUILD_GIMP_GPL)
foreach (MC_VERSION IN LISTS MC_VERSIONS)
set(PALETTE_FILE_NAME "rgba-${MC_VERSION}.txt")
set(GIMP_FILE_PREFIX "Minecraft${MC_VERSION}")
add_custom_target("gen_gimp_palettes_${MC_VERSION}" ALL
DEPENDS gen_gimp_palette
COMMAND $<TARGET_FILE:gen_gimp_palette> "${CMAKE_CURRENT_SOURCE_DIR}/${PALETTE_FILE_NAME}" "${GIMP_FILE_PREFIX}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${GIMP_FILE_PREFIX}.gpl" DESTINATION ${GIMP_PALETTE_DIR})
endforeach ()
endif ()

0 comments on commit 4612c70

Please sign in to comment.