#=============================================================================
# The CMakeLists for the libUnitTest project.
#
# This is supposed to be maintained by hand and not get generated 
# automatically like other CMakeLists
#
# ----------------------------------------------------------------------------
# Copyright 2018 Autodesk, Inc.  All rights reserved.
#
# This computer source code and related instructions and comments are the
# unpublished confidential and proprietary information of Autodesk, Inc. and
# are protected under applicable copyright and trade secret law.  They may not
# be disclosed to, copied or used by any third party without the prior
# written consent of Autodesk, Inc.
# ----------------------------------------------------------------------------

#=============================================================================

cmake_minimum_required(VERSION 3.9)

project(libUnitTest)

set(CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED ${CMAKE_CURRENT_SOURCE_DIR}/Autogenerated)
if (FALSE)
### The API generation target
if (WIN32)
	set(ACT_COMMANDENDING bat)
elseif (UNIX)
	set(ACT_COMMANDENDING sh)
endif ()
add_custom_command(
    OUTPUT
		${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Bindings/Cpp/libunittest.cpp
		${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Source/Implementation/libunittest_interfaceexception.cpp
		${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Source/Implementation/libunittest_interfacewrapper.cpp
    DEPENDS
        ${CMAKE_CURRENT_SOURCE_DIR}/AutomaticComponentToolkit/libunittest.xml
    WORKING_DIRECTORY
        ${CMAKE_CURRENT_SOURCE_DIR}/AutomaticComponentToolkit
    COMMAND
        ${CMAKE_CURRENT_SOURCE_DIR}/AutomaticComponentToolkit/automaticcomponenttoolkit.${ACT_COMMANDENDING} ${CMAKE_CURRENT_SOURCE_DIR}/AutomaticComponentToolkit/libunittest.xml ${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}
    COMMENT
        "Generating hourglass API bindings and implementation stub"
	VERBATIM
    )
add_custom_target(libunittestACT DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/AutomaticComponentToolkit/libunittest.xml)

endif()

### The hourglass API of the libunittest
file(GLOB LIBUNITTEST_SRC
	"Source/Custom/*.cpp"
	"Source/Additional/*.cpp"
)
set(LIBUNITTEST_SRC ${LIBUNITTEST_SRC}
	"${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Source/Implementation/libunittest_interfaceexception.cpp"
	"${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Source/Implementation/libunittest_interfacejournal.cpp"
	"${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Source/Implementation/libunittest_interfacewrapper.cpp")

add_library(libunittest SHARED ${LIBUNITTEST_SRC})
target_compile_options(libunittest PRIVATE "-D__LIBUNITTEST_DLL")
target_include_directories(libunittest PRIVATE ${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Source/Implementation)
target_include_directories(libunittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Source/Stub)
	
# add_dependencies(libunittest libunittestACT)

### The test application for the Machining component
option(USECPPSTATICAPI "Should the test application for libunittest use the dynamic or static C++-bindings?"
       ON)
file(GLOB MACHININGTEST_SRC
	"libunittestTest/main.cpp"
)
if(${USECPPSTATICAPI})
	set(MACHININGTEST_SRC ${MACHININGTEST_SRC} "${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Bindings/Cpp/libunittest.cpp")
endif()

add_executable(libunittestTest ${MACHININGTEST_SRC})
target_link_libraries(libunittestTest libunittest)
if(${USECPPSTATICAPI})
	target_include_directories(libunittestTest PUBLIC ${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Bindings/Cpp)
else()
	target_include_directories(libunittestTest PUBLIC ${CMAKE_CURRENT_BINARY_DIR_AUTOGENERATED}/Bindings/CppDynamic)
	target_compile_options(libunittestTest PRIVATE "-DLIBUNITTESTUSECPPDYNAMIC")
endif()
