WSL/SLF GitLab Repository

CMakeLists.txt 3.84 KB
Newer Older
1
2
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/")

3
4
SET(LIBPREFIX "lib") #make sure ALL plugins are libXXX for ALL plateforms
SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") #for Visual C++ import libraries
5
OPTION( BUILD_SHARED_LIBS "Set to ON to build dynamic libraries" ON )
6
7
8
9
10
11
IF(WIN32)
	#otherwise the lib files are not generated
	SET(BUILD_STATIC_LIBS ON)
ELSE(WIN32)
	OPTION( BUILD_STATIC_LIBS "Set to ON to build static libraries" OFF )
ENDIF(WIN32)
12
13
14
IF(APPLE)
	SET(EXTRA_LINK_FLAGS "-framework CoreFoundation")
ENDIF(APPLE)
15

16
IF(PROJ4)
17
18
19
	FIND_PATH(LIBPROJ_INCLUDE_DIR "proj_api.h")
	FIND_LIBRARY(LIBPROJ proj)
	INCLUDE_DIRECTORIES(${LIBPROJ_INCLUDE_DIR})
20
21
22
23
24
	IF(MSVC)
		ADD_DEFINITIONS(/DPROJ4) #it looks like some VC++ versions don't support -D syntax
	ELSE(MSVC)
		ADD_DEFINITIONS(-DPROJ4)
	ENDIF(MSVC)
25
26
ENDIF(PROJ4)

27
INCLUDE("${PROJECT_SOURCE_DIR}/meteoio/plugins/CMakeLists.txt")
28
INCLUDE("${PROJECT_SOURCE_DIR}/meteoio/meteolaws/CMakeLists.txt")
29
INCLUDE("${PROJECT_SOURCE_DIR}/meteoio/meteostats/CMakeLists.txt")
30
INCLUDE("${PROJECT_SOURCE_DIR}/meteoio/meteofilters/CMakeLists.txt")
31

32
IF(POPC)
33
	#FIND_PACKAGE(Popc REQUIRED)
34
	SET(popc_sources marshal_meteoio.cc)
35
	SET(CMAKE_CXX_COMPILER popcc) #this does not work, the user still has to do it manually
36
37
38
	#INCLUDE(CMakeForceCompiler)
	#CMAKE_FORCE_CXX_COMPILER(popcc POPCC)
	SET(POPC_EXT "popc")
39
40
ENDIF(POPC)

41
SET(meteoio_sources
42
	IOManager.cc
43
	Matrix.cc
44
	IOPlugin.cc
45
46
	MeteoProcessor.cc
	ResamplingAlgorithms.cc
47
	ResamplingAlgorithms2D.cc
48
	Meteo1DInterpolator.cc
49
	InterpolationAlgorithms.cc
50
51
	DataGenerator.cc
	GeneratorAlgorithms.cc
52
53
54
55
	Date.cc
	Timer.cc
	Grid2DObject.cc
	IOHandler.cc
56
	Coords.cc
57
	Graphics.cc
58
59
60
61
62
	Meteo2DInterpolator.cc
	BufferedIOHandler.cc
	DEMObject.cc
	Grid3DObject.cc
	IOInterface.cc
63
	StationData.cc
64
65
	Config.cc
	IOExceptions.cc
66
67
	IOUtils.cc
	MeteoData.cc
68
	plugins/libsmet.cc
69
	${plugins_sources}
70
	${meteolaws_sources}
71
	${meteostats_sources}
72
	${meteofilters_sources}
73
	${popc_sources}
74
)
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
IF(GUI_EXCEPTIONS)
	IF(MSVC)
		ADD_DEFINITIONS(/DMSG_BOX)
	ELSE(MSVC)
		ADD_DEFINITIONS(-DMSG_BOX)
	ENDIF(MSVC)
	IF(UNIX AND NOT APPLE AND NOT CYGWIN)
		FIND_PACKAGE(X11)
		IF(X11_FOUND)
			INCLUDE_DIRECTORIES(SYSTEM ${X11_INCLUDE_DIR})
			SET(GUI_LIBS ${X11_LIBRARIES})
			LIST(APPEND meteoio_sources MessageBoxX11.cc)
		ELSE(X11_FOUND)
			SET(GUI_EXCEPTIONS) #unsets the variable
		ENDIF(X11_FOUND)
	ENDIF(UNIX AND NOT APPLE AND NOT CYGWIN)
ENDIF(GUI_EXCEPTIONS)
92

93
94
IF(BUILD_STATIC_LIBS)
	SET(STATICNAME ${PROJECT_NAME}_STATIC)
95
	SET(STATICLIBNAME ${PROJECT_NAME}${POPC_EXT})
96
	ADD_LIBRARY(${STATICNAME} STATIC ${meteoio_sources})
97
	TARGET_LINK_LIBRARIES(${STATICNAME} ${plugin_libs} ${LIBPROJ} ${Popc_LIBRARIES} ${EXTRA_LINK_FLAGS} ${GUI_LIBS})
98
ENDIF(BUILD_STATIC_LIBS)
99

100
SET(SHAREDNAME ${PROJECT_NAME}${POPC_EXT})
101
ADD_LIBRARY(${SHAREDNAME} ${meteoio_sources})
102
TARGET_LINK_LIBRARIES(${SHAREDNAME} ${plugin_libs} ${LIBPROJ} ${Popc_LIBRARIES} ${EXTRA_LINK_FLAGS} ${GUI_LIBS})
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
SET_TARGET_PROPERTIES(${SHAREDNAME} PROPERTIES
	PREFIX "${LIBPREFIX}"
	LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
	ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
	RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
	CLEAN_DIRECT_OUTPUT 1
	VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
	SOVERSION "${VERSION_MAJOR}"
)
INSTALL(TARGETS ${SHAREDNAME}
	RUNTIME DESTINATION lib
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib
	COMPONENT libraries
)
118

119
#static library. Please keep in mind that for Windows, a dll is a runtime
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
IF(BUILD_STATIC_LIBS)
	SET_TARGET_PROPERTIES(${STATICNAME} PROPERTIES
		PREFIX "${LIBPREFIX}"
		LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
		ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
		RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
		CLEAN_DIRECT_OUTPUT 1
		OUTPUT_NAME ${STATICLIBNAME}
	)
	INSTALL(TARGETS ${STATICNAME}
		RUNTIME DESTINATION lib
		LIBRARY DESTINATION lib
		ARCHIVE DESTINATION lib
		COMPONENT libraries
	)
ENDIF(BUILD_STATIC_LIBS)