Skip to content

Commit

Permalink
Provide list of DLLs via CMake Fucntion + windows fixes/up
Browse files Browse the repository at this point in the history
  • Loading branch information
ptheywood committed Nov 30, 2022
1 parent bfbfcda commit ccc414c
Showing 1 changed file with 48 additions and 6 deletions.
54 changes: 48 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,35 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_
endif()

target_link_libraries("${PROJECT_NAME}" PRIVATE glm::glm)
# GLEW::GLEW which is an alias for GLEW::glew or GLEW::glew_s based on availability.
target_link_libraries("${PROJECT_NAME}" PRIVATE GLEW::GLEW)
target_link_libraries("${PROJECT_NAME}" PRIVATE SDL2::SDL2)
target_link_libraries("${PROJECT_NAME}" PRIVATE "${IL_LIBRARIES}")
# Use GLEW::GLEW if available, otherwise fallback to the variables only (i.e. custom windows fetching)
if(TARGET GLEW::GLEW)
target_link_libraries("${PROJECT_NAME}" PRIVATE GLEW::GLEW)
elseif(GLEW_INCLUDE_DIRS)
target_include_directories("${PROJECT_NAME}" SYSTEM PRIVATE ${GLEW_INCLUDE_DIRS})
target_link_libraries("${PROJECT_NAME}" PRIVATE "${GLEW_LIBRARIES}")
endif()
# Use SDL2::SDL2 if available, otherwise fallback to the variables only (i.e. custom windows fetching)
if(TARGET SDL2::SDL2)
target_link_libraries("${PROJECT_NAME}" PRIVATE SDL2::SDL2)
elseif(SDL2_INCLUDE_DIRS)
target_include_directories("${PROJECT_NAME}" SYSTEM PRIVATE ${SDL2_INCLUDE_DIRS})
# Ubuntu 16.04 workaround
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
target_link_libraries("${PROJECT_NAME}" PRIVATE "${SDL2_LIBRARIES}")
endif()
# Use DevIL::IL if available, otherwise fallback to the variables only (i.e. custom windows fetching)
if(TARGET DevIL::IL)
target_link_libraries("${PROJECT_NAME}" PRIVATE DevIL::IL)
elseif(IL_INCLUDE_DIR)
target_include_directories("${PROJECT_NAME}" SYSTEM PRIVATE ${IL_INCLUDE_DIR})
target_link_libraries("${PROJECT_NAME}" PRIVATE "${IL_LIBRARIES}")
endif()
# imgui must be public as the headers are visible in flamegpu/FLAMEGPU2
target_link_libraries("${PROJECT_NAME}" PUBLIC ImGui::ImGui)
# GL required
target_link_libraries("${PROJECT_NAME}" PRIVATE OpenGL::GL)
# std::threads support
target_link_libraries("${PROJECT_NAME}" PRIVATE Threads::Threads)
# imgui must be public as the headers are visible in flamegpu/FLAMEGPU2
target_link_libraries("${PROJECT_NAME}" PUBLIC ImGui::ImGui)
# Link against freetype, via Freetype::Freetype if imported, or just freetype otherwise
if(TARGET Freetype::Freetype)
target_link_libraries("${PROJECT_NAME}" PRIVATE Freetype::Freetype)
Expand All @@ -294,6 +315,7 @@ endif()
if(TARGET Fontconfig::Fontconfig)
target_link_libraries("${PROJECT_NAME}" PRIVATE Fontconfig::Fontconfig)
endif()
# dwrite.lib required on windows
if(WIN32)
target_link_libraries("${PROJECT_NAME}" PRIVATE "dwrite.lib")
endif()
Expand Down Expand Up @@ -340,6 +362,26 @@ set_property(TARGET "resources" PROPERTY POSITION_INDEPENDENT_CODE ON)
# Link resources and the visualiser static lib
target_link_libraries("${PROJECT_NAME}" PUBLIC resources)

# Define a function to list the runtime libraries for the visualiser static lib, for downstream targets to copy to any required locations (i.e. pyflamegpu). This reduces the amount of overlap.
if (NOT COMMAND flamegpu_visualiser_get_runtime_depenencies)
function(flamegpu_visualiser_get_runtime_depenencies runtime_dependencies)
# windows only, and only with non-target dependencies. Fancier CMake based dependency stuff might be possible, but might require newer cmake or an install phase
if(WIN32)
if(SDL2_RUNTIME_LIBRARIES)
LIST(APPEND runtime_libs ${SDL2_RUNTIME_LIBRARIES})
endif()
if(GLEW_RUNTIME_LIBRARIES)
LIST(APPEND runtime_libs ${GLEW_RUNTIME_LIBRARIES})
endif()
if(IL_RUNTIME_LIBRARIES)
LIST(APPEND runtime_libs ${IL_RUNTIME_LIBRARIES})
endif()
endif()
# Return the value to the calling scope
set(${runtime_dependencies} "${runtime_libs}" PARENT_SCOPE)
endfunction()
endif()

if (CMAKE_USE_FOLDERS)
# Setup Visual Studio (and eclipse) filters
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down

0 comments on commit ccc414c

Please sign in to comment.