
#####----------GLOBAL_DEFINITION-----###

#add_definitions(-DORACLE)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)



######---------MSVC-----------#######

set(MSVC_COMPILE_OPTION ${MSVC_COMPILE_OPTION}
/W4 
)

set(MSVC_COMPILE_OPTION_DEBUG ${MSVC_COMPILE_OPTION_DEBUG}
/Z7
)

set(MSVC_COMPILE_OPTION_RELEASE ${MSVC_COMPILE_OPTION_RELEASE}
/Ob1 /O2  #Og
)

set(MSVC_DEFINE_OPTION ${MSVC_DEFINE_OPTION}

)

set(MSVC_DEFINE_OPTION_DEBUG ${MSVC_DEFINE_OPTION_DEBUG}

)

set(MSVC_DEFINE_OPTION_RELEASE ${MSVC_DEFINE_OPTION_RELEASE}

)

set(MSVC_LINKER_OPTION ${MSVC_LINKER_OPTION}

)

set(MSVC_LINKER_OPTION_DEBUG ${MSVC_LINKER_OPTION_DEBUG}

)

set(MSVC_LINKER_OPTION_RELEASE ${MSVC_LINKER_OPTION_RELEASE}

)



######---------GCC-----------#######


set(GCC_COMPILE_OPTION ${GCC_COMPILE_OPTION}
-Wall  -fPIC
)

set(GCC_COMPILE_OPTION_DEBUG ${GCC_COMPILE_OPTION_DEBUG}
#-fprofile-arcs -ftest-coverage
)

set(GCC_COMPILE_OPTION_RELEASE ${GCC_COMPILE_OPTION_RELEASE}
-O3 -fPIC 
)

set(GCC_DEFINE_OPTION ${GCC_DEFINE_OPTION}

)

set(GCC_DEFINE_OPTION_DEBUG ${GCC_DEFINE_OPTION_DEBUG}

)

set(GCC_DEFINE_OPTION_RELEASE ${GCC_DEFINE_OPTION_RELEASE}

)

set(GCC_LINKER_OPTION   ${GCC_LINKER_OPTION}

)

set(GCC_LINKER_OPTION_DEBUG ${GCC_LINKER_OPTION_DEBUG}

)

set(GCC_LINKER_OPTION_RELEASE ${GCC_LINKER_OPTION_RELEASE}

)


function(configure_global_compile_options)

	add_library(project_global_options INTERFACE)
	
    set( DEFINE_OPTION  "")
    set( COMPILE_OPTION "")
	set( LINKER_OPTION  "")
	#set global options
	if(MSVC) 
		set( DEFINE_OPTION 
		     ${MSVC_DEFINE_OPTION}
		     $<IF:$<CONFIG:DEBUG>,${MSVC_DEFINE_OPTION_DEBUG}
					,${MSVC_DEFINE_OPTION_RELEASE}>
			 )
		set( COMPILE_OPTION 
		     ${MSVC_COMPILE_OPTION}
		     $<IF:$<CONFIG:DEBUG>,${MSVC_COMPILE_OPTION_DEBUG}
					,${MSVC_COMPILE_OPTION_RELEASE}>
			 )
			 
	    set( LINKER_OPTION 
		     ${MSVC_LINKER_OPTION}
		     $<IF:$<CONFIG:DEBUG>,${MSVC_LINKER_OPTION_DEBUG}
					,${MSVC_LINKER_OPTION_RELEASE}>
			 )
    elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")	 
		set( DEFINE_OPTION 
		     ${GCC_DEFINE_OPTION}
		     $<IF:$<CONFIG:DEBUG>,${GCC_DEFINE_OPTION_DEBUG}
					,${GCC_DEFINE_OPTION_RELEASE}>
			 )
		set( COMPILE_OPTION 
		     ${GCC_COMPILE_OPTION}
		     $<IF:$<CONFIG:DEBUG>,${GCC_COMPILE_OPTION_DEBUG}
					,${GCC_COMPILE_OPTION_RELEASE}>
			 )
			 
	     set( LINKER_OPTION 
		     ${GCC_LINKER_OPTION}
		     $<IF:$<CONFIG:DEBUG>,${GCC_LINKER_OPTION_DEBUG}
					,${GCC_LINKER_OPTION_RELEASE}>
			 )
	endif()
	
	#Add them to the global project target
	target_compile_definitions(project_global_options INTERFACE 
			 ${DEFINE_OPTION}
		 )
		 
	target_compile_options(project_global_options INTERFACE 
		     ${COMPILE_OPTION} 
			 ${LINKER_OPTION}
		 )

endfunction()