|
1 | 1 | cmake_minimum_required(VERSION 3.22) |
2 | 2 | project(sorting-visualizer) |
3 | 3 |
|
4 | | -set(SFML_DIR "lib/SFML-2.5.1/lib/cmake/SFML") |
| 4 | +set(default_build_type "Release") |
| 5 | +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
| 6 | + message( STATUS "Setting build type to '${default_build_type}' as none was specified.") |
| 7 | + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) |
| 8 | + # Set the possible values of build type for cmake-gui |
| 9 | + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS |
| 10 | + "Debug" "Release" "MinSizeRel" "RelWithDebInfo") |
| 11 | +endif() |
5 | 12 |
|
| 13 | +set(SFML_DIR "C:/Program Files (x86)/SFML/lib/cmake/SFML") |
6 | 14 |
|
7 | | -find_package(SFML COMPONENTS graphics window REQUIRED) |
| 15 | +find_package(SFML COMPONENTS graphics window CONFIG REQUIRED) |
8 | 16 |
|
9 | 17 | add_executable(sorting-visualizer src/main.cpp src/Sortable.cpp src/SortAlgorithms.cpp src/SortController.cpp src/Utils.cpp) |
10 | 18 |
|
11 | 19 | target_link_libraries(sorting-visualizer sfml-graphics sfml-window) |
12 | 20 |
|
| 21 | +# Copy across .dlls for windows users |
| 22 | +get_target_property(SFML_TYPE sfml-graphics TYPE) |
| 23 | +if(SFML_TYPE STREQUAL "SHARED_LIBRARY") |
| 24 | + message(STATUS "Copying sfml-graphics DLLs to ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>") |
| 25 | + add_custom_command( |
| 26 | + TARGET sorting-visualizer POST_BUILD |
| 27 | + COMMAND ${CMAKE_COMMAND} -E copy |
| 28 | + $<TARGET_FILE:sfml-graphics> |
| 29 | + ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>) |
| 30 | + |
| 31 | + message(STATUS "Copying sfml-window DLLs to ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>") |
| 32 | + add_custom_command( |
| 33 | + TARGET sorting-visualizer POST_BUILD |
| 34 | + COMMAND ${CMAKE_COMMAND} -E copy |
| 35 | + $<TARGET_FILE:sfml-window> |
| 36 | + ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>) |
| 37 | + |
| 38 | + message(STATUS "Copying sfml-system DLLs to ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>") |
| 39 | + add_custom_command( |
| 40 | + TARGET sorting-visualizer POST_BUILD |
| 41 | + COMMAND ${CMAKE_COMMAND} -E copy |
| 42 | + $<TARGET_FILE:sfml-system> |
| 43 | + ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>) |
| 44 | +endif() |
| 45 | + |
0 commit comments