Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (MSVC)
endif ()

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/dep/superluminal/API")

include(${PROJECT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)

Expand Down Expand Up @@ -108,6 +109,7 @@ target_compile_definitions(SimpleGraphic
"GLFW_INCLUDE_NONE"
"GL_SILENCE_DEPRECATION"
"SIMPLEGRAPHIC_EXPORTS"
"PERFORMANCEAPI_ENABLED=$<BOOL:${SuperluminalAPI_FOUND}>"
)

target_include_directories(SimpleGraphic
Expand All @@ -126,6 +128,7 @@ find_package(Microsoft.GSL CONFIG REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(re2 CONFIG REQUIRED)
find_package(sol2 CONFIG REQUIRED)
find_package(SuperluminalAPI)
find_package(Threads REQUIRED)
find_package(zstd REQUIRED)
find_package(ZLIB REQUIRED)
Expand Down Expand Up @@ -187,6 +190,7 @@ target_include_directories(SimpleGraphic
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/dep/glad/include
${CMAKE_CURRENT_SOURCE_DIR}/dep/stb
${CMAKE_CURRENT_SOURCE_DIR}/dep/superluminal/API/include
)

if (CMAKE_SYSTEM_NAME MATCHES "Linux")
Expand All @@ -212,6 +216,13 @@ if (WIN32)
PRIVATE
"winmm.lib"
)

if (SuperluminalAPI_FOUND)
target_link_libraries(SimpleGraphic
PRIVATE
SuperluminalAPI
)
endif ()
endif ()

if (APPLE)
Expand Down
83 changes: 83 additions & 0 deletions dep/superluminal/API/FindSuperluminalAPI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This module can be used to find the Superluminal API libs & headers via find_package.
#
# For example: find_package(SuperluminalAPI REQUIRED)
#
# You can use it by adding the API directory of your Superluminal install to your CMAKE_PREFIX_PATH, or alternatively
# by copying the entire API directory to a place of your own choosing and adding that location to CMAKE_PREFIX_PATH.
#
# The following (optional) variables can be set prior to issueing the find_package command:
# - SuperluminalAPI_ROOT : The root directory where the libs & headers should be found. For example <SuperluminalInstallDir>\API.
# If this is not set, the libs & headers are assumed to be next to the location of FindSuperluminalAPI.cmake
# - SuperluminalAPI_USE_STATIC_RUNTIME : If this is set, the libraries linked to the static C runtime (i.e. /MT and /MTd) will be returned
# If not set, the libraries linked to the dynamic C runtime (i.e. /MD and /MDd) will be returned
#
# On completion of find_package, the following variables will be set:
#
# SuperluminalAPI_FOUND : Whether the package was found
# SuperluminalAPI_LIBS_RELEASE : The Release libraries to link against
# SuperluminalAPI_LIBS_DEBUG : The Debug libraries to link against
# SuperluminalAPI_INCLUDE_DIRS : The include directories to use
#
# In addition, if find_package completed successfully, the target "SuperluminalAPI" will be defined.
# You should prefer to consume this target via target_link_libraries(YOUR_TARGET PRIVATE SuperluminalAPI), rather than by using the above variables directly
SET(SuperluminalAPI_SEARCH_PATHS
${CMAKE_CURRENT_LIST_DIR}
${SuperluminalAPI_ROOT}
)

find_path(SuperluminalAPI_INCLUDE_DIRS Superluminal/PerformanceAPI.h
PATHS ${SuperluminalAPI_SEARCH_PATHS}
PATH_SUFFIXES include
)

if (CMAKE_SIZEOF_VOID_P MATCHES 4)
set(SELECTED_ARCH "x86")
else(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(SELECTED_ARCH "x64")
endif()

if(WIN32)
if (NOT (${MSVC_VERSION} LESS 1900)) # Test for VS2015 and higher (older CMake versions don't have a >= operator)
if (${SuperluminalAPI_USE_STATIC_RUNTIME})
find_library(SuperluminalAPI_LIBS_RELEASE
NAMES PerformanceAPI_MT
PATH_SUFFIXES lib/${SELECTED_ARCH}
PATHS ${SuperluminalAPI_SEARCH_PATHS}
)

find_library(SuperluminalAPI_LIBS_DEBUG
NAMES PerformanceAPI_MTd
PATH_SUFFIXES lib/${SELECTED_ARCH}
PATHS ${SuperluminalAPI_SEARCH_PATHS}
)
else()
find_library(SuperluminalAPI_LIBS_RELEASE
NAMES PerformanceAPI_MD
PATH_SUFFIXES lib/${SELECTED_ARCH}
PATHS ${SuperluminalAPI_SEARCH_PATHS}
)

find_library(SuperluminalAPI_LIBS_DEBUG
NAMES PerformanceAPI_MDd
PATH_SUFFIXES lib/${SELECTED_ARCH}
PATHS ${SuperluminalAPI_SEARCH_PATHS}
)
endif()
else()
message(SEND_ERROR "Your Visual Studio version is not currently supported. Please contact Superluminal support.")
endif()
endif()

mark_as_advanced(SuperluminalAPI_FOUND)
mark_as_advanced(SuperluminalAPI_LIBS_RELEASE)
mark_as_advanced(SuperluminalAPI_LIBS_DEBUG)
mark_as_advanced(SuperluminalAPI_INCLUDE_DIRS)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SuperluminalAPI REQUIRED_VARS SuperluminalAPI_INCLUDE_DIRS SuperluminalAPI_LIBS_RELEASE SuperluminalAPI_LIBS_DEBUG)

if(SuperluminalAPI_FOUND AND NOT TARGET SuperluminalAPI)
add_library(SuperluminalAPI INTERFACE IMPORTED)
target_include_directories(SuperluminalAPI INTERFACE "${SuperluminalAPI_INCLUDE_DIRS}")
target_link_libraries(SuperluminalAPI INTERFACE debug "${SuperluminalAPI_LIBS_DEBUG}" optimized "${SuperluminalAPI_LIBS_RELEASE}" )
endif()
Binary file not shown.
Loading
Loading