include(FindPackageHandleStandardArgs)

file(
	GLOB
	SOQT_INCLUDE_PATHS
	$ENV{COINDIR}/include
	$ENV{COIN3DDIR}/include
	$ENV{HOME}/include
	/usr/local/include
	/usr/include/Coin*
	/usr/include
	$ENV{SystemDrive}/Coin*/include
	$ENV{ProgramW6432}/Coin*/include
	$ENV{ProgramFiles}/Coin*/include
)

file(
	GLOB
	SOQT_LIBRARY_PATHS
	$ENV{COINDIR}/lib
	$ENV{COIN3DDIR}/lib
	$ENV{HOME}/lib
	/usr/local/lib
	/usr/lib
	$ENV{SystemDrive}/Coin*/lib
	$ENV{ProgramW6432}/Coin*/lib
	$ENV{ProgramFiles}/Coin*/lib
)

find_path(
	SOQT_INCLUDE_DIRS
	NAMES
	Inventor/Qt/SoQt.h
	HINTS
	${SOQT_INCLUDE_PATHS}
)

find_library(
	SOQT_LIBRARY_DEBUG
	NAMES
	SoQtd soqt1d
	HINTS
	${SOQT_LIBRARY_PATHS}
)

find_library(
	SOQT_LIBRARY_RELEASE
	NAMES
	SoQt soqt1
	HINTS
	${SOQT_LIBRARY_PATHS}
)

set(SOQT_DEFINITIONS -DSOQT_NOT_DLL)

if(SOQT_LIBRARY_DEBUG AND NOT SOQT_LIBRARY_RELEASE)
	set(SOQT_LIBRARIES ${SOQT_LIBRARY_DEBUG})
endif(SOQT_LIBRARY_DEBUG AND NOT SOQT_LIBRARY_RELEASE)

if(SOQT_LIBRARY_RELEASE AND NOT SOQT_LIBRARY_DEBUG)
	set(SOQT_LIBRARIES ${SOQT_LIBRARY_RELEASE})
endif(SOQT_LIBRARY_RELEASE AND NOT SOQT_LIBRARY_DEBUG)

if(SOQT_LIBRARY_DEBUG AND SOQT_LIBRARY_RELEASE)
	set(SOQT_LIBRARIES debug ${SOQT_LIBRARY_DEBUG} optimized ${SOQT_LIBRARY_RELEASE})
endif(SOQT_LIBRARY_DEBUG AND SOQT_LIBRARY_RELEASE)

find_package_handle_standard_args(
	SoQt
	DEFAULT_MSG
	SOQT_INCLUDE_DIRS
	SOQT_LIBRARIES
)

mark_as_advanced(
	SOQT_DEFINITIONS
	SOQT_INCLUDE_DIRS
	SOQT_LIBRARIES
	SOQT_LIBRARY_DEBUG
	SOQT_LIBRARY_RELEASE
) 
