#
# $Id: ConfigUserTemplate.cmake 9093 2011-09-24 15:21:21Z fwobbe $
#
# Use this file to override variables in 'ConfigDefault.cmake' on a per-user basis.
# 'ConfigUser.cmake' is not version controlled.
#

# Set build type can be: empty, Debug, Release, relwithdebinfo or minsizerel (default is Release)
set(CMAKE_BUILD_TYPE Release)

# Por causa das Merdas da 'Policia'
add_definitions(/DDEBUG)
#add_definitions(/DDEBUG_MODERN)
add_definitions(/DMEMDEBUG)
add_definitions(/DUSE_COMMON_LONG_OPTIONS)
add_definitions(/DUSE_MODULE_LONG_OPTIONS)

#set (CMAKE_C_COMPILER "C:/Program Files (x86)/Intel/Composer XE/bin/intel64/icl.exe")
#set (CMAKE_CXX_COMPILER "C:/Program Files (x86)/Intel/Composer XE/bin/intel64/icl.exe")


# =================== Other than me, users should only need to edit this block ==================
if (WIN32)
	# ------- The compiler. Either VC12 or VC14 for VS2012 or VS2015/17
	set (VC VC14)

	# ------- The GMT version. Used to find the GMTMEX dir and to set GMT install path ----------
	set (GMTver gmt6)

	# ------- WHERE TO INSTALL GMT (Full name will be $GMT_INSTALL_DIR/compileds/$GMTver/VCXX_32|64) ------
	set(GMT_INSTALL_DIR "C:/progs_cygw/GMTdev/gmt5")

	# ------- The GSHHG and DCW files location --------------------------------------------------
	set (GSHHG_ROOT ${GMT_INSTALL_DIR}/master/share/coast)
	set (GSHHG_PATH ${GMT_INSTALL_DIR}/master/share/coast)
	set (GSHHG_VERSION "2.3")
	set (GSHHG_FOUND TRUE)
	set (DCW_ROOT   ${GMT_INSTALL_DIR}/master/share/dcw)

	# ------- The GDAL_DATA, PROJ_LIB & GHOST files location -----------------------------------------
	set (GDAL_DATA_PATH C:/programs/compa_libs/gdal_GIT/compileds/VC14_64/data)
	set (PROJ_DATA_PATH C:/programs/compa_libs/proj5_GIT/compileds/VC14_64/share/proj)
	set (GHOST_DATA_PATH C:/programs/compa_libs/ghostscript/bin)

	# ------- The GMTMEX location ---------------------------------------------------------------
	set (GMTMEX_PATH "C:/progs_cygw/GMTdev/gmtmex/${GMTver}")


	# ------- Set root dir to ALL the dependencies (JL's Dropbox libs) **JL DOES NOT NEED** -----
	#set (DEPS_ROOT C:/Dropbox/libs_JL)
endif ()
# ================================================================================================

# Copy GSHHG files to $/coast [FALSE]:
set (COPY_GSHHG TRUE)

# Copy DCW files to $/dcw [FALSE]:
set (COPY_DCW TRUE)

set (GMT_ENABLE_OPENMP TRUE)

# Exclude optional GDAL, PCRE, FFTW3, LAPACK, ZLIB dependencies even if you have them installed [FALSE]
# set (GMT_EXCLUDE_GDAL TRUE)
#set (GMT_DATA_URL "data_server_url")	# For future, when we have other choices
set (GRAPHICSMAGICK_RMS "0.005")

enable_testing()
set (DO_EXAMPLES ON)
set (DO_TESTS ON)
set (DO_ANIMATIONS ON)
set (DO_API_TESTS ON)		# Build only during devel stages
set (GMT_INSTALL_MODULE_LINKS TRUE)


#if (UNIX)
#	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -pg")
#endif ()

if (WIN32)

	#SET(MKL_FLAGS "/Qmkl /fast")
	#SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} ${MKL_FLAGS} /W4 /guard:cf" )
	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} ${MKL_FLAGS}")

	set (BITAGE 32)
	# Detect if we are building a 32 or 64 bits version
	if (CMAKE_SIZEOF_VOID_P EQUAL 8)
		set(BITAGE 64)
	endif ()
	set (GMT_DLL_RENAME gmt_w${BITAGE})
	set (PSL_DLL_RENAME postscriptlight_w${BITAGE})
	set (SUPP_DLL_RENAME supplements_w${BITAGE})

	# Extra no warnings
	set (CMAKE_C_FLAGS "/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE ${CMAKE_C_FLAGS}")
	set (CMAKE_C_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE ${CMAKE_C_FLAGS}")

	# This mine (JL) default location (if not set in first "if (WIN32)" block) for the dependency libs
	if (NOT DEPS_ROOT)
		set (DEPS_ROOT C:/programs/compa_libs)
		set (COMP_SUBDIR compileds)
	endif ()

	# Installation path
	set(CMAKE_INSTALL_PREFIX "${GMT_INSTALL_DIR}/compileds/${GMTver}/${VC}_${BITAGE}")

	# gmtmex instalation path
	set (GMTMEX_PATH "${GMTMEX_PATH}/${VC}_${BITAGE}")

	# set location of netcdf (can be root directory, path to header file or path to nc-config):
	set(NETCDF_DIR "${DEPS_ROOT}/netcdf_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}")
	set(NETCDF_LIBRARY "${DEPS_ROOT}/netcdf_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/netcdf.lib")

	# set location of pcre (can be root directory, path to header file or path to nc-config):
	set(PCRE_DIR "${DEPS_ROOT}/pcre_SVN/${COMP_SUBDIR}/${VC}_${BITAGE}")
	set(PCRE_LIBRARY "${DEPS_ROOT}/pcre_SVN/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/pcre.lib")

	# set location of gdal (can be root directory, path to header file or path to gdal-config):
	set(GDAL_DIR     "${DEPS_ROOT}/gdal_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}")
	set(GDAL_LIBRARY "${DEPS_ROOT}/gdal_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/gdal_i.lib")

	# set location of MikTex
	set(MIKTEX_BINARY_PATH "C:/programs/miktex/miktex/bin")

	# Set location of single precision FFTW (can be root directory or path to header file) [auto]:
	set (FFTW3_ROOT "${DEPS_ROOT}/fftw-3.3.8/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/")
	set (FFTW3_INCLUDE_DIR "${DEPS_ROOT}/fftw-3.3.8/${COMP_SUBDIR}/${VC}_${BITAGE}/include/")
	set (FFTW3F_LIBRARY "${DEPS_ROOT}/fftw-3.3.8/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/fftw3f.lib")

	# Set location of ZLIB (can be root directory or path to header file) [auto]:
	set (ZLIB_ROOT        "${DEPS_ROOT}/zlib-1.2.11/${COMP_SUBDIR}/${VC}_${BITAGE}/")
	set (ZLIB_INCLUDE_DIRS "${DEPS_ROOT}/zlib-1.2.11/${COMP_SUBDIR}/${VC}_${BITAGE}/include/")
	set (ZLIB_LIBRARY     "${DEPS_ROOT}/zlib-1.2.11/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/zlib.lib")

	# Set location of CURL
	set (CURL_ROOT        "${DEPS_ROOT}/curl-7.54.0/${COMP_SUBDIR}/${VC}_${BITAGE}/")
	set (CURL_INCLUDE_DIR "${DEPS_ROOT}/curl-7.54.0/${COMP_SUBDIR}/${VC}_${BITAGE}/include/")
	set (CURL_LIBRARY     "${DEPS_ROOT}/curl-7.54.0/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/libcurl.lib")

	# Set location of GLIB ...:
	set (GMT_USE_THREADS TRUE)
	set (GLIB_INCLUDE_DIR "${DEPS_ROOT}/glib-2.38.2/${COMP_SUBDIR}/${VC}_${BITAGE}/include/glib-2.0")
	set (GLIB_LIBRARIES   "${DEPS_ROOT}/glib-2.38.2/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/glib-2.0.lib")

	# Set LAPACK location. Use this when want to link with LAPACK and it's not found automatically
	if (BITAGE EQUAL 64)
		set (LAPACK_LIBRARY "${DEPS_ROOT}/lapack-3.5.0/${COMP_SUBDIR}/lib/liblapack.lib")
		set (BLAS_LIBRARY "${DEPS_ROOT}/lapack-3.5.0/${COMP_SUBDIR}/lib/libblas.lib")
	endif ()

	#set (LAPACK_LIBRARY "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\mkl/lib/intel64/mkl_core_dll.lib")

	set (GEOS_INCLUDE_DIR "${DEPS_ROOT}/geos-3.8.1/${COMP_SUBDIR}/${VC}_${BITAGE}/include/")
	set (GEOS_LIBRARY     "${DEPS_ROOT}/geos-3.8.1/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/geos_c.lib")

	# CPACK doesn't copy the omp dll probably becuase it uses the loadlibrary dynamic linking tech
	if (BITAGE EQUAL 64)
		if (VC STREQUAL "VC12")
			set (OMP_DLL_LOC "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/redist/x64/Microsoft.VC120.OPENMP/vcomp120.dll")
		else ()
			set (OMP_DLL_LOC "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Redist/MSVC/14.23.27820/x64/Microsoft.VC142.OPENMP/vcomp140.dll")
		endif ()
	else (BITAGE EQUAL 64)
		if (VC STREQUAL "VC12")
			set (OMP_DLL_LOC "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/redist/x86/Microsoft.VC120.OPENMP/vcomp120.dll")
		else ()
			set (OMP_DLL_LOC "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Redist/MSVC/14.23.27820/x86/Microsoft.VC142.OPENMP/vcomp140.dll")
		endif ()
	endif (BITAGE EQUAL 64)

	# If GDAL was built with PROJ as a dynamic loading lib, tell CPACK that it needs to be packed too.
	set (DLL_PLUGINS "${DEPS_ROOT}/proj5_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/proj_w${BITAGE}.dll")
endif ()


# Extra debugging for developers:
#add_definitions(/DNDEBUG)
#add_definitions(/D_DEBUG)
#add_definitions(/DDEBUG_RUNPATH)
#add_definitions(/DDOUBLE_PRECISION_GRID)
add_definitions(/DWITH_OGRREAD)


# For MB
if (FALSE AND WIN32)

	#set (MB_ROOT C:/progs_cygw/MB-GMT5)
	set (MB_ROOT C:/progs_cygw/MB-Qt)

	set(SUPPL_EXTRA_DIRS mb)
	#set (EXTRA_MODULES_SUPPL "mb/suppl_add_mb.txt")	# This include(s) will add new modules to the official GMT supplements

	#set (EXTRA_INCLUDE_NEWSUPPL "mb/plug_mb.txt")	# This include will create new pluggins
	set (MB_DLL_RENAME mbgmt_w${BITAGE})

	set (PROJLIB   "${DEPS_ROOT}/proj5_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/proj.lib")
	set (ONCRPCLIB "${DEPS_ROOT}/oncrpc/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/oncrpc.lib")
	set (GETOPTLIB "${DEPS_ROOT}/getopt/${COMP_SUBDIR}/${VC}_${BITAGE}/lib/getopt.lib")

	set (MBIOLIB   "${MB_ROOT}/${COMP_SUBDIR}/${VC}_${BITAGE}/bin/mbio.lib")
	set (MBAUXLIB  "${MB_ROOT}/${COMP_SUBDIR}/${VC}_${BITAGE}/bin/mbaux.lib")
	#set (MBIOLIB   "${MB_ROOT}/lib64_dbg/mbio.lib")
	#set (MBAUXLIB  "${MB_ROOT}/lib64_dbg/mbaux.lib")

	set (MBINC      "${MB_ROOT}/include")
	set (ONCRPCINC  "${DEPS_ROOT}/oncrpc/${COMP_SUBDIR}/${VC}_${BITAGE}/include")
	set (GETOPTINC  "${DEPS_ROOT}/getopt/${COMP_SUBDIR}/${VC}_${BITAGE}/include")
	set (PROJINCDIR "${DEPS_ROOT}/proj5_GIT/${COMP_SUBDIR}/${VC}_${BITAGE}/include")

	set (PTHREADINC "${DEPS_ROOT}/pthreads/compileds/${VC}_${BITAGE}/include")
	set (PTHREADLIB "${DEPS_ROOT}/pthreads/compileds/${VC}_${BITAGE}/lib/pthreadVC2.lib")

	# .../cmake/dist/CMakeList.txt Import a list of files to add to the installer
	set (EXTRA_INCLUDE_EXES "../../src/mb/add_exes_cpack.txt")

else ()
	if (WIN32)
		# .../cmake/dist/CMakeList.txt Import a list of files to add to the installer
		#set (EXTRA_INCLUDE_EXES "../../cmake/dist/add_exes_cpack.txt")
		set (EXTRA_INCLUDE_EXES "../../admin/add_windows_cpack.txt")
	endif ()
endif ()

# For GS_RASTERIZE
if (FALSE)
	set (EXTRA_INCLUDE_GMTSUPPL "gs_rasterize/suppl_add_gs.txt")	# This include(s) will add new modules to the official GMT supplements
	#set (EXTRA_BUILD_DIRS gs_rasterize)		# Tell src/CMakeList.txt to build the GS supplement

	set (EXTRA_INCLUDE_NEWSUPPL "gs_rasterize/plug_gs.txt")		# This include declares extra include dirs and libs needed to build the plug-in
	set (GS_DLL_RENAME gsrasterize_w${BITAGE})
endif ()

# For GMT_CUSTOM
if (FALSE)
	set (EXTRA_INCLUDE_NEWSUPPL "custom/plug_custom.txt")	# This include will create a new pluggin
	set (CUSTOM_DLL_RENAME custom_w${BITAGE})
endif ()

if (__MINGW32__)
	set(NETCDF_DIR "C:/MinGW/msys/1.0/local/include")
	set(NETCDF_LIBRARY "C:/MinGW/msys/1.0/local/lib/libnetcdf.a")
endif (__MINGW32__)