Alpine3D

Alpine3D Svn Source Tree

Root/trunk/alpine3d/CMakeLists.txt

1INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/")
2
3INCLUDE("${PROJECT_SOURCE_DIR}/alpine3d/ebalance/CMakeLists.txt")
4INCLUDE("${PROJECT_SOURCE_DIR}/alpine3d/runoff/CMakeLists.txt")
5INCLUDE("${PROJECT_SOURCE_DIR}/alpine3d/snowdrift/CMakeLists.txt")
6
7FIND_PACKAGE(MeteoIO)
8FIND_PACKAGE(Libsnowpack)
9INCLUDE_DIRECTORIES(${LIBSNOWPACK_INCLUDE_DIR} ${METEOIO_INCLUDE_DIR})
10SET(extra_libs ${extra_libs} ${LIBSNOWPACK_LIBRARY} ${METEOIO_LIBRARIES})
11
12IF(PETSC)
13FIND_PACKAGE(PETSc REQUIRED)
14INCLUDE_DIRECTORIES(${PETSC_INCLUDES}})
15SET(extra_libs ${extra_libs} ${PETSC_LIBRARIES})
16ENDIF(PETSC)
17IF(MPI)
18FIND_PACKAGE(MPI REQUIRED)
19INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
20SET(extra_libs ${extra_libs} ${MPI_CXX_LIBRARIES})
21ENDIF(MPI)
22
23SET(a3d_sources
24${ebalance_sources}
25${runoff_sources}
26${snowdrift_sources}
27SnowpackInterfaceWorker.cc
28SnowpackInterface.cc
29Glaciers.cc
30TechSnowA3D.cc
31DataAssimilation.cc
32MeteoObj.cc
33MPIControl.cc
34OMPControl.cc
35)
36
37#shared library
38IF(BUILD_SHARED_LIBS)
39SET(SHAREDNAME ${PROJECT_NAME})
40ADD_LIBRARY(${SHAREDNAME} ${a3d_sources})
41TARGET_LINK_LIBRARIES(${SHAREDNAME} ${extra_libs})
42SET_TARGET_PROPERTIES(${SHAREDNAME} PROPERTIES
43MACOSX_RPATH TRUE
44PREFIX "${LIBPREFIX}"
45LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/${LIB_DEST}"
46ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/${LIB_DEST}"
47RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/${LIB_DEST}"
48CLEAN_DIRECT_OUTPUT 1
49VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
50SOVERSION "${VERSION_MAJOR}"
51)
52INSTALL(TARGETS ${SHAREDNAME}
53RUNTIME DESTINATION "${LIB_DEST}" COMPONENT exe
54LIBRARY DESTINATION "${LIB_DEST}" COMPONENT exe
55ARCHIVE DESTINATION "${LIB_DEST}" COMPONENT exe
56)
57ENDIF(BUILD_SHARED_LIBS)
58
59#static library. Please keep in mind that for Windows, a dll is a runtime
60IF(BUILD_STATIC_LIBS)
61SET(STATICNAME ${PROJECT_NAME}_STATIC)
62SET(STATICLIBNAME ${PROJECT_NAME})
63ADD_LIBRARY(${STATICNAME} STATIC ${a3d_sources})
64TARGET_LINK_LIBRARIES(${STATICNAME} ${extra_libs})
65SET_TARGET_PROPERTIES(${STATICNAME} PROPERTIES
66MACOSX_RPATH TRUE
67PREFIX "${LIBPREFIX}"
68LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
69ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
70RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib"
71CLEAN_DIRECT_OUTPUT 1
72OUTPUT_NAME ${STATICLIBNAME}
73)
74INSTALL(TARGETS ${STATICNAME}
75RUNTIME DESTINATION bin COMPONENT libraries
76LIBRARY DESTINATION lib COMPONENT libraries
77ARCHIVE DESTINATION lib COMPONENT libraries
78)
79ENDIF(BUILD_STATIC_LIBS)
80
81#################################################################################
82# And now, build the binary
83
84IF(ALPINE3D_STANDALONE)
85SET(a3d_main
86AlpineControl.cc
87AlpineMain.cc
88)
89
90#get the proper Snowpack library
91IF(BUILD_SHARED_LIBS)
92SET(LIBALPINE3D_LIBRARY ${PROJECT_NAME})
93ELSE(BUILD_SHARED_LIBS)
94IF(BUILD_STATIC_LIBS)
95SET(LIBALPINE3D_LIBRARY "${PROJECT_NAME}_STATIC")
96ELSE(BUILD_STATIC_LIBS)
97MESSAGE(SEND_ERROR "Not building Alpine3D, the standalone application won't be able to build")
98ENDIF(BUILD_STATIC_LIBS)
99ENDIF(BUILD_SHARED_LIBS)
100
101#LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/lib)
102SET(A3D_LINKS ${extra_libs})
103IF(APPLE)
104#this is necessary for GUI exceptions
105LIST(APPEND A3D_LINKS "-framework CoreServices")
106ENDIF(APPLE)
107IF(UNIX)
108LIST(APPEND A3D_LINKS "dl;pthread")
109ENDIF(UNIX)
110
111#Prepare executable
112SET(BINARY "alpine3d.app")
113ADD_EXECUTABLE(${BINARY} ${a3d_main})
114TARGET_LINK_LIBRARIES(${BINARY} ${LIBALPINE3D_LIBRARY} ${A3D_LINKS})
115
116SET_TARGET_PROPERTIES(${BINARY} PROPERTIES
117RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
118CLEAN_DIRECT_OUTPUT 1
119OUTPUT_NAME "alpine3d"
120)
121
122INSTALL(TARGETS ${BINARY}
123RUNTIME DESTINATION bin
124COMPONENT exe
125)
126ENDIF(ALPINE3D_STANDALONE)

Archive Download this file

Revision: HEAD