cmake_minimum_required(VERSION 3.9)

# Try to find the SketchUp SDK and load it.  It can be referenced in the code by using the 'SKPSDK' target name.
if(NOT SKPSDK_CHECK_RUN)
	set(SKPSDK_CHECK_RUN TRUE)

	if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/FindSKPSDK.Win32.cmake")
		set(SKPSDK_FOUND TRUE)
		find_package(SKPSDK.Win32 COMPONENTS ${CMAKE_GENERATOR_PLATFORM})
		message(STATUS "Found SKPSDK.Win32")
	elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/binaries/sketchup/x64/SketchUpAPI.dll" AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64")
		set(SKPSDK_FOUND TRUE)
		set(SKPSDK_MULTI_FILES TRUE)
		add_library(SKPSDK SHARED IMPORTED GLOBAL)
		set_target_properties(SKPSDK PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/headers")
		set_target_properties(SKPSDK PROPERTIES IMPORTED_IMPLIB "${CMAKE_CURRENT_LIST_DIR}/binaries/sketchup/x64/SketchUpAPI.lib")
		set_target_properties(SKPSDK PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/binaries/sketchup/x64/SketchUpAPI.dll")
		set_target_properties(SKPSDK PROPERTIES IMPORTED_LINK_DEPENDENT_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/binaries/sketchup/x64/SketchUpCommonPreferences.dll")
		message(STATUS "Loaded SKPSDK")
	else()
		set(SKPSDK_FOUND FALSE)
		message(STATUS "SKPSDK not found.")
	endif()
endif()
