# Copyright (c) 2010-2015:  G-CSC, Goethe University Frankfurt
# Author: Sebastian Reiter
# 
# This file is part of UG4.
# 
# UG4 is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License version 3 (as published by the
# Free Software Foundation) with the following additional attribution
# requirements (according to LGPL/GPL v3 §7):
# 
# (1) The following notice must be displayed in the Appropriate Legal Notices
# of covered and combined works: "Based on UG4 (www.ug4.org/license)".
# 
# (2) The following notice must be displayed at a prominent place in the
# terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
# 
# (3) The following bibliography is recommended for citation and must be
# preserved in all covered files:
# "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
#   parallel geometric multigrid solver on hierarchically distributed grids.
#   Computing and visualization in science 16, 4 (2013), 151-164"
# "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
#   flexible software system for simulating pde based models on high performance
#   computers. Computing and visualization in science 16, 4 (2013), 165-179"
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.

include("../../../cmake/ug_cmake_versions.cmake")

# Creating python library for 'ugcore'
project(UG_PYBIND11)

if(USE_PYBIND11)
	SET(pyModuleName pyugcore) # Must match module name!
	pybind11_add_module(${pyModuleName} ug_pybind.cpp python_user_data.cpp python_views.cpp)
	set_target_properties(${pyModuleName} PROPERTIES	
  		CXX_STANDARD 11 
  		CXX_STANDARD_REQUIRED YES
   		CXX_EXTENSIONS NO)
   		
   	# '$targetLibraryName' is either ug4 or ug4_s	
   	MESSAGE(STATUS "Using libug4 ${targetLibraryName}") 
	target_link_libraries (${pyModuleName} PUBLIC ${targetLibraryName} CompileInfo)
	
	# Install module into 'ug4py'
	install(TARGETS ${pyModuleName} LIBRARY DESTINATION ug4py COMPONENT pymodules)
	
	
	if(APPLE)
		# message (STATUS "Fixing RELOC path")
    	# set_target_properties(${targetLibraryName} PROPERTIES
        #	INSTALL_RPATH "@loader_path"
    	# )
    	
    	# set(CMAKE_MACOSX_RPATH ON)

		# set_target_properties(${targetLibraryName} PROPERTIES INSTALL_NAME_DIR "@loader_path")
		#set_target_properties(${pyModuleName} PROPERTIES INSTALL_RPATH "@loader_path")
		#target_link_options(${pyModuleName} PRIVATE "-Wl,-rpath,@loader_path")
	endif()
	

	
endif(USE_PYBIND11)