CMakeLists.txt 5.33 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
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
11
12
13
set(CMAKE_MODULE_PATH 
	${CMAKE_SOURCE_DIR}/CMake
	${CMAKE_SOURCE_DIR}/CMake/TestingSuite)
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
14

15
16
17
18
19
20
21
22
23
24
25
26
27
# Should we build with testing
option(XDMF_BUILD_TESTING OFF)
if(XDMF_BUILD_TESTING)
	enable_testing()
	include(CTest)
endif(XDMF_BUILD_TESTING)

# Should we build with documentation
option(XDMF_BUILD_DOCUMENTATION OFF)
if(XDMF_BUILD_DOCUMENTATION)
	add_subdirectory(doc)
endif(XDMF_BUILD_DOCUMENTATION)

28
29
30
31
32
33
34
35
36
37
38
39
# 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)
40
	find_package(PythonInterp REQUIRED)
41
42
43
44
45
46
	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
47
48
49
50
51
	# 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
52
53
	MACRO(XDMF_SWIG_PYTHON python_name)
		set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR})
54
		set(CMAKE_SWIG_FLAGS "")
55
56
57
		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})
58
59
60
61
		set_property(DIRECTORY APPEND PROPERTY
			ADDITIONAL_MAKE_CLEAN_FILES
			${CMAKE_BINARY_DIR}/${python_name}.pyc
		)	
62
63
64
		if("${ARGN}" STRGREATER "")
			add_dependencies(${python_name} "${ARGN}")
		endif("${ARGN}" STRGREATER "")
65
66
67
68
69
70
71
72
73
74
75
76
77
78
		install(FILES ${CMAKE_BINARY_DIR}/Xdmf.py DESTINATION lib/python)
		install(TARGETS ${SWIG_MODULE_Xdmf_REAL_NAME} DESTINATION lib/python)
	ENDMACRO(XDMF_SWIG_PYTHON)
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
79
80
81
82
83
84
	# 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
85
	MACRO(XDMF_SWIG_JAVA java_name)
86
		set(XDMF_JAVA_PACKAGE_DIR mil/army/arl/xdmf)
87
		set(XDMF_JAVA_DIR ${CMAKE_CURRENT_BINARY_DIR}/${XDMF_JAVA_PACKAGE_DIR})
88
89
90
91
		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)
92
93
		swig_link_libraries(${java_name}Java ${java_name})	
		add_dependencies(${java_name}Java ${java_name}JavaDir)
94
95
96
97
98
99
		if("${ARGN}" STRGREATER "")
			add_dependencies(${java_name}Java "${ARGN}")
		endif("${ARGN}" STRGREATER "")
		add_custom_command(TARGET ${java_name}Java
			POST_BUILD 	
			COMMAND ${JAVA_COMPILE}
100
			ARGS 	 -cp "'${CMAKE_BINARY_DIR}/*'"
101
102
103
104
105
					 "${XDMF_JAVA_DIR}/*.java"
			COMMAND ${JAVA_ARCHIVE}
			ARGS	-cvf ${CMAKE_BINARY_DIR}/${java_name}.jar
					"${XDMF_JAVA_PACKAGE_DIR}/*.class"
		)
106
107
108
109
110
111
112
113
114
115
116
117
118
119
		add_custom_target(
			${java_name}JavaDir ALL
			DEPENDS ${XDMF_JAVA_DIR}
		)	
		add_custom_command(
			OUTPUT ${XDMF_JAVA_DIR}
			COMMAND ${CMAKE_COMMAND} -E make_directory
				${XDMF_JAVA_DIR}
		)
		set_property(DIRECTORY APPEND PROPERTY
			ADDITIONAL_MAKE_CLEAN_FILES
			${CMAKE_BINARY_DIR}/${java_name}.jar
			${XDMF_JAVA_DIR}
		)
120
121
122
	ENDMACRO(XDMF_SWIG_JAVA)
endif(XDMF_WRAP_JAVA)

123
124
add_subdirectory(core)
include_directories(${XdmfCore_INCLUDE_DIRS})
125

126
127
128
129
130
131
132
133
134
135
136
137
option(XDMF_BUILD_CORE_ONLY OFF)
if(NOT XDMF_BUILD_CORE_ONLY)
	set(XdmfSources
		XdmfAttribute
		XdmfAttributeCenter
		XdmfAttributeType
		XdmfDomain
		XdmfGeometry
		XdmfGeometryType
		XdmfGrid
		XdmfGridCollection
		XdmfGridCollectionType
138
		XdmfGridCurvilinear
139
		XdmfGridRectilinear
140
		XdmfGridRegular
141
		XdmfGridUnstructured
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
		XdmfItemFactory
		XdmfMap
		XdmfReader
		XdmfSet
		XdmfSetType
		XdmfTime
		XdmfTopology
		XdmfTopologyType
	)
	
	add_library(Xdmf ${XdmfSources})
	target_link_libraries(Xdmf XdmfCore)
	
	if(XDMF_WRAP_JAVA)
		XDMF_SWIG_JAVA(Xdmf XdmfCoreJava)
		set(XDMF_JAVA_JAR ${CMAKE_BINARY_DIR}/Xdmf.jar CACHE INTERNAL "")
	endif(XDMF_WRAP_JAVA)
	
160
161
162
163
	if(XDMF_WRAP_PYTHON)
		XDMF_SWIG_PYTHON(Xdmf XdmfCore)
	endif(XDMF_WRAP_PYTHON)
	
164
	if(XDMF_BUILD_TESTING)
165
		include_directories(tests/Cxx)
166
167
168
169
170
171
172
173
174
175
176
177
		add_subdirectory(tests)
	endif(XDMF_BUILD_TESTING)
	
	option(XDMF_BUILD_UTILS OFF)
	if(XDMF_BUILD_UTILS)
		add_subdirectory(utils)
	endif(XDMF_BUILD_UTILS)
		
	file(GLOB XdmfHeaders *.hpp)
	install(FILES ${XdmfHeaders} DESTINATION include)
	install(TARGETS Xdmf LIBRARY DESTINATION lib)
endif(NOT XDMF_BUILD_CORE_ONLY)