Skip to content

Commit

Permalink
CMake installation setup, windows exe icon
Browse files Browse the repository at this point in the history
  • Loading branch information
setghm committed Jan 3, 2025
1 parent 232f31e commit 0b2bb9c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*.kate-swp
*~

# Exclude CMake Genetarion.
# Exclude CMake Genetarion and build directories.
/cmake-build-debug/
/cmake-build-release/
/build/
/out/
/out/
/installed/
30 changes: 28 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,37 @@ list(APPEND SourceFiles
${GameSources}
)

add_executable(${APPNAME} ${SourceFiles})
# Add resources for each platform.

if (WIN32)
list(APPEND SourceFiles "res/windows/resource.rc")
endif()

# Add the executable.

if (WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Release")
# In release mode on Windows don't show the console window setting the target
# executable to a Win32 application.
add_executable(${APPNAME} WIN32 ${SourceFiles})
else()
add_executable(${APPNAME} ${SourceFiles})
endif()

target_link_libraries(${APPNAME} SDL2::SDL2 SDL2::SDL2main SDL2_image::SDL2_image SDL2_mixer::SDL2_mixer m)

if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET ${APPNAME} PROPERTY C_STANDARD 11)
endif()

add_custom_command(TARGET ${APPNAME} POST_BUILD COMMAND ${APPNAME} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
# After the build copy the assets folder into the build directory.

file(COPY "${PROJECT_SOURCE_DIR}/assets" DESTINATION ${CMAKE_BINARY_DIR})

# Configure installation target.

set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/installed")
install(TARGETS ${APPNAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
install(DIRECTORY "${PROJECT_SOURCE_DIR}/assets" DESTINATION ${CMAKE_INSTALL_PREFIX})

file(GLOB_RECURSE DYNAMIC_LIBS "${CMAKE_BINARY_DIR}/*.dll" "${CMAKE_BINARY_DIR}/*.so")
install(FILES ${DYNAMIC_LIBS} DESTINATION ${CMAKE_INSTALL_PREFIX})
Binary file added res/windows/icon.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions res/windows/resource.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Set the windows executable file icon.
0 ICON "icon.ico"

0 comments on commit 0b2bb9c

Please sign in to comment.