# This cmake configuration was originally created by meemknight on github # https://github.com/meemknight/cmakeSetup # It has been modified for use in this repository by Colton Staiduhar cmake_minimum_required(VERSION 3.16) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Release>") # Declare Project where "GSM_TEMPLATE" is the project name project(GSM_TEMPLATE LANGUAGES C CXX) # Allow cmake to fetch web repositories include(FetchContent) # Set the location for downloaded libraries set(THIRDPARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty") set(FETCHCONTENT_BASE_DIR "${THIRDPARTY_DIR}") # Fetch the miniaudio Repository and install it FetchContent_Declare( miniaudio GIT_REPOSITORY git@github.com:mackron/miniaudio.git GIT_TAG "master" GIT_SHALLOW TRUE GIT_PROGRESS ON SYSTEM ) FetchContent_MakeAvailable(miniaudio) # Fetch the STB-Image Repository and install it FetchContent_Declare( stb_image GIT_REPOSITORY git@github.com:arizotaz/cmake_stb_image GIT_TAG "master" GIT_SHALLOW TRUE GIT_PROGRESS ON SYSTEM ) FetchContent_MakeAvailable(stb_image) # Tell Cmake to find the locations of libraries find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) # Define MY_SOURCES to be a list of all the source files for my game file(GLOB_RECURSE MY_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") add_executable("${CMAKE_PROJECT_NAME}") # Set the C++ standard to 17 set_property(TARGET "${CMAKE_PROJECT_NAME}" PROPERTY CXX_STANDARD 17) #======================================================================================== # CHANGE RESOURCES DEFINITION #======================================================================================== # You will change which line is commented depending # on if the compiled binary is for development or # production. # # Uncomment the line below when in development, this uses the resources folder # in the CMake project for the RESOURCES_PATH definition target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/") # # Uncomment the line below when in production, this uses a folder in the same working # directory of the binary called "resources". Effectively RESOURCES_PATH # becomes ./resources/. You would copy the resources folder of the cmake project # and ship it will the compiled binary #target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC RESOURCES_PATH="./resources/") # # Add our sources target_sources("${CMAKE_PROJECT_NAME}" PRIVATE ${MY_SOURCES} ) # If using the VS compiler if(MSVC) target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC _CRT_SECURE_NO_WARNINGS) #remove console #set_target_properties("${CMAKE_PROJECT_NAME}" PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") set_property(TARGET "${CMAKE_PROJECT_NAME}" PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDebug<$:Debug>") set_property(TARGET "${CMAKE_PROJECT_NAME}" PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Release>") endif() # Add our include files target_include_directories("${CMAKE_PROJECT_NAME}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/") # Disable different warning (Glut is really old, we already know that) target_compile_options("${CMAKE_PROJECT_NAME}" PRIVATE -Wno-deprecated-declarations -Wdelete-incomplete $<$:-Wno-pedantic -Wno-macro-redefined> ) # Include the libraries loaded earlier target_link_libraries("${CMAKE_PROJECT_NAME}" PRIVATE OpenGL::GL "-framework GLUT" "-lpthread" "-lm" stb_image miniaudio )