CMakeLists.txt 4.35 KB
Newer Older
1
project(Xdmf)
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
2
3
4
cmake_minimum_required(VERSION 2.6)

set(BUILD_SHARED_LIBS true)
5
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
6
7
8
9
SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 
SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
10
11
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake ${CMAKE_CURRENT_SOURCE_DIR}/core/CMake)
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Wrapper Setup
option(XDMF_WRAP_PYTHON OFF)
option(XDMF_WRAP_JAVA OFF)

# If we are wrapping either, we need swig
if(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA)
	find_package(SWIG REQUIRED)
	include(${SWIG_USE_FILE})
endif(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA)

# If we are wrapping python, let's include it in the top level
if(XDMF_WRAP_PYTHON)
	find_package(PythonLibs REQUIRED)
	include_directories(${PYTHON_INCLUDE_DIRS})

	# A macro to swig and create the python files
	# Since we essentually do the same thing inside and outside core, it
	# would be easier as a macro
31
32
33
34
35
	# Parameters:
	#	python_name = the name of the intended target to be wrapped
	#	${ARGN} = any dependencies needed by the target
	# Output:
	#	Target Name = the output target name will have ${python_name} as its name
36
37
38
39
40
	MACRO(XDMF_SWIG_PYTHON python_name)
		set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR})
		set_source_files_properties(${python_name}.i PROPERTIES CPLUSPLUS ON)
		swig_add_module(${python_name} python ${python_name}.i)
		swig_link_libraries(${python_name} ${python_name} ${PYTHON_LIBRARIES})
41
42
43
		if("${ARGN}" STRGREATER "")
			add_dependencies(${python_name} "${ARGN}")
		endif("${ARGN}" STRGREATER "")
44
45
46
47
		install(FILES ${CMAKE_BINARY_DIR}/Xdmf.py DESTINATION lib/python)
		install(TARGETS ${SWIG_MODULE_Xdmf_REAL_NAME} DESTINATION lib/python)
	ENDMACRO(XDMF_SWIG_PYTHON)
	
48
	XDMF_SWIG_PYTHON(Xdmf XdmfCore)
49
50
51
52
53
54
55
56
57
58
59
endif(XDMF_WRAP_PYTHON)

# If we are wrapping java, let's include it in the top level
if(XDMF_WRAP_JAVA)
	find_package(Java REQUIRED)
	find_package(JNI REQUIRED)
	include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})

	# A macro to swig and create the jar files
	# Since we essentually do the same thing inside and outside core, it
	# would be easier as a macro
60
61
62
63
64
65
	# Parameters:
	#	java_name = the name of the intended target to be wrapped
	#	${ARGN} = any dependencies needed by the target
	# Output:
	#	Target Name	= the output target name will have ${java_name}Java as its name
	#	Target Jar	= the output target jar will have ${java_name}Java.jar as its name
66
	MACRO(XDMF_SWIG_JAVA java_name)
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
		set(XDMF_JAVA_PACKAGE_DIR mil/army/arl/xdmf)
		set(XDMF_JAVA_DIR ${CMAKE_CURRENT_BINARY_DIR}/${XDMF_JAVA_PACKAGE_DIR})
		file(MAKE_DIRECTORY ${XDMF_JAVA_DIR})

		set(CMAKE_SWIG_OUTDIR ${XDMF_JAVA_DIR})
		set(CMAKE_SWIG_FLAGS -v -make_default -package mil.army.arl.xdmf)
		set_source_files_properties(${java_name}.i PROPERTIES CPLUSPLUS ON)
		swig_add_module(${java_name}Java java ${java_name}.i)
		swig_link_libraries(${java_name}Java ${java_name})

		if("${ARGN}" STRGREATER "")
			add_dependencies(${java_name}Java "${ARGN}")
		endif("${ARGN}" STRGREATER "")
		
		add_custom_command(TARGET ${java_name}Java
			POST_BUILD 	
			COMMAND ${JAVA_COMPILE}
84
			ARGS 	 -cp "'${CMAKE_BINARY_DIR}/*'"
85
86
87
88
89
90
91
					 "${XDMF_JAVA_DIR}/*.java"
			COMMAND ${JAVA_ARCHIVE}
			ARGS	-cvf ${CMAKE_BINARY_DIR}/${java_name}.jar
					"${XDMF_JAVA_PACKAGE_DIR}/*.class"
		)
	ENDMACRO(XDMF_SWIG_JAVA)
	
92
	XDMF_SWIG_JAVA(Xdmf XdmfCoreJava)
93
94
95
	set(XDMF_JAVA_JAR ${CMAKE_BINARY_DIR}/Xdmf.jar CACHE INTERNAL "")
endif(XDMF_WRAP_JAVA)

96
97
add_subdirectory(core)
include_directories(${XdmfCore_INCLUDE_DIRS})
98
include_directories(tests/Cxx)
99
100

set(XdmfSources
101
	XdmfAttribute
102
	XdmfAttributeCenter
103
	XdmfAttributeType
104
	XdmfDomain
105
	XdmfGeometry
106
	XdmfGeometryType
107
	XdmfGrid
108
109
	XdmfGridCollection
	XdmfGridCollectionType
110
	XdmfItemFactory
111
	XdmfMap
112
	XdmfReader
113
114
	XdmfSet
	XdmfSetType
115
	XdmfTime
116
	XdmfTopology
117
	XdmfTopologyType
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
118
119
120
)

add_library(Xdmf ${XdmfSources})
121
target_link_libraries(Xdmf XdmfCore)
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
122

123
124
option(XDMF_BUILD_DOCUMENTATION OFF)
if(XDMF_BUILD_DOCUMENTATION)
125
	add_subdirectory(doc)
126
endif(XDMF_BUILD_DOCUMENTATION)
127

128
129
130
131
132
option(XDMF_BUILD_UTILS OFF)
if(XDMF_BUILD_UTILS)
	add_subdirectory(utils)
endif(XDMF_BUILD_UTILS)

133
134
135
file(GLOB XdmfHeaders *.hpp)
install(FILES ${XdmfHeaders} DESTINATION include)
install(TARGETS Xdmf LIBRARY DESTINATION lib)
136

137
138
139
140
141
if(XDMF_BUILD_TESTING)
	enable_testing()
	add_subdirectory(tests)
endif(XDMF_BUILD_TESTING)