cmake_minimum_required(VERSION 3.10)

# Sample CMakeLists.txt for building an application using AGX.
project(HelloWorld)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED On)
set(CMAKE_CXX_EXTENSIONS Off)


# Check so that the setup_env environment file has been executed:
if ("$ENV{AGX_DIR}"  STREQUAL "")
  message(WARNING "\n*** The environment initialization file setup_env.bat/bash has not been executed\n*** Errors might occur during runtime!")
endif()

# Configure CMake Module path so we can locate FindAGX.cmake
set(AGX_DIR $ENV{AGX_DIR})
set(CMAKE_MODULE_PATH "${AGX_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")

# Now locate AGX
find_package(AGX REQUIRED)
# find_package(OSG)


if (MSVC)
  # Exclude CMakeLists.txt from .vcproj
  set(CMAKE_SUPPRESS_REGENERATION "1")
  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else()
  # On non-windows, fallback to release libraries if debug version is not available.
  set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG Debug Release)
endif()


# We want paths embedded in binaries (e.g tutorials) that are built on OSes that supports
# this feature so that required libraries are found more easily.
# CMake will embed paths by default in the build tree, this block is needed to also
# have paths in the install tree.
set(CMAKE_SKIP_RPATH FALSE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Use different name for libraries depending on build mode
set(CMAKE_DEBUG_POSTFIX "d" )

# Build the program
add_executable(HelloWorld HelloWorld.cpp)

# Use debug prefix on the executable as well.
set_target_properties(HelloWorld PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

# Link to AGX targets. These targets also provides path to include files that are needed.
target_link_libraries(HelloWorld PRIVATE AGX::agxCore AGX::agxPhysics AGX::agxModel AGX::agxCable AGX::agxTerrain AGX::agxHydraulics AGX::agxVehicle)

# If OSG is used, uncomment OSG-related find- and link commands.
# target_link_libraries(HelloWorld PRIVATE AGX::agxOSG OSG::osg OSG::osgUtil OSG::osgDB OSG::osgText OSG::osgViewer OSG::osgShadow )

# Specify an install target directory
install(TARGETS HelloWorld RUNTIME DESTINATION bin/ )

