CMakeLists.txt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. cmake_minimum_required(VERSION 3.16.0)
  2. set(CMAKE_C_STANDARD 90)
  3. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  4. project(IC_Explorer)
  5. find_package(PkgConfig REQUIRED)
  6. pkg_check_modules(SDL2 REQUIRED sdl2 SDL2_mixer SDL2_image SDL2_ttf)
  7. function(add_resources out_var)
  8. set(result)
  9. foreach(in_f ${ARGN})
  10. file(RELATIVE_PATH src_f ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${in_f})
  11. set(out_f ${PROJECT_BINARY_DIR}/${in_f}.o)
  12. get_filename_component(f_name ${src_f} NAME)
  13. get_filename_component(f_dir ${src_f} DIRECTORY)
  14. file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${f_dir})
  15. add_custom_command(OUTPUT ${out_f}
  16. COMMAND ld -r -b binary -o ${out_f} ${f_name}
  17. DEPENDS ${in_f}
  18. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${f_dir}
  19. COMMENT "Building resource ${out_f}"
  20. VERBATIM)
  21. list(APPEND result ${out_f})
  22. endforeach()
  23. set(${out_var} "${result}" PARENT_SCOPE)
  24. endfunction()
  25. add_resources(RESOURCES assets/font.ttf assets/background.png
  26. assets/button.png assets/button-pressed.png assets/mute.png
  27. assets/volume.png assets/bgm.wav assets/hover.wav assets/click.wav
  28. assets/release.wav)
  29. include_directories(${SDL2_INCLUDE_DIRS})
  30. link_directories(${SDL2_LIBRARY_DIRS})
  31. add_definitions(${SDL2_CFLAGS_OTHER} "-Wall")
  32. add_executable(IC_Explorer main.c window.c button.c textbox.c ${RESOURCES})
  33. target_link_libraries(IC_Explorer ${SDL2_LIBRARIES})