xref: /phasta/phSolver/incompressible/CMakeLists.txt (revision e85dd27f78178cea4be54ab557d502f6f4401775)
1file(GLOB SRC_FILES *.cc *.f *.f90 *.c)
2list(REMOVE_ITEM SRC_FILES "main.cc")
3
4option(PHASTA_USE_LESLIB "Use LESLIB Solver" OFF)
5
6if(PHASTA_USE_SVLS)
7	add_definitions(-DHAVE_SVLS)
8endif()
9
10if(PHASTA_USE_LESLIB)
11	add_definitions(-DHAVE_LESLIB)
12else()
13 list(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/usr.c )
14 list(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/getSol.c )
15 list(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/lestools.c )
16 list(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/lesSparse.f )
17 list(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/ftools.f )
18endif()
19
20if(NOT PHASTA_USE_SVLS AND NOT PHASTA_USE_LESLIB)
21  message(FATAL_ERROR
22"At least one of the incompressible solvers must be enabled \
23via PHASTA_USE_SVLS and/or PHASTA_USE_LESLIB"
24  )
25endif()
26
27
28add_library(incompressible ${SRC_FILES})
29
30find_package(phastaCommon REQUIRED PATHS ${CMAKE_BINARY_DIR})
31set(PHASTAIC_LIBS ${CMAKE_THREAD_LIBS_INIT} ${PHASTA_COMMON_LIBS})
32set(PHASTAIC_INCLUDE_DIRS
33  ${PHASTAIC_INCLUDE_DIRS}
34  ${PHASTA_COMMON_INCLUDE_DIRS}
35  ${PHASTA_BINARY_DIR}
36)
37
38add_executable(phastaIC.exe main.cc)
39include_directories(${PHASTAIC_INCLUDE_DIRS})
40set_target_properties(phastaIC.exe PROPERTIES HAS_CXX TRUE)
41set_target_properties(incompressible PROPERTIES HAS_CXX TRUE)
42set_target_properties(phastaIC.exe PROPERTIES LINKER_LANGUAGE Fortran)
43set_target_properties(incompressible PROPERTIES LINKER_LANGUAGE Fortran)
44if(CMAKE_Fortran_COMPILER_ID MATCHES XL)
45	#force preprocessing of solfar.f
46	set_source_files_properties(solfar.f PROPERTIES COMPILE_FLAGS "-qsuffix=cpp=f")
47	set_source_files_properties(itrdrv.f PROPERTIES COMPILE_FLAGS "-qsuffix=cpp=f")
48	set_source_files_properties(filters.f PROPERTIES COMPILE_FLAGS "-qsuffix=cpp=f")
49endif(CMAKE_Fortran_COMPILER_ID MATCHES XL)
50if(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
51	#force preprocessing of solfar.f
52	set_source_files_properties(solfar.f PROPERTIES COMPILE_FLAGS "-Mpreprocess")
53endif(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
54#incompressible reuses a fortran module from common w/o telling cmake
55#this is why we specify a module directory in the next cmakelists up
56#and we need to serialize incompressible after common
57add_dependencies(incompressible common)
58if( PHASTA_USE_LESLIB AND PHASTA_USE_SVLS )
59message(STATUS "using SVLS and LESLIB")
60set(PHASTAIC_LIBS
61  ${PHASTA_COMMON_LIBS}
62  incompressible
63  ${LESLIB}
64  svLS
65  incompressible
66  ${PHASTA_COMMON_LIBS}
67)
68
69elseif(PHASTA_USE_LESLIB)
70message(STATUS "using LESLIB")
71  find_library(LESLIB libles)
72  set(PHASTAIC_LIBS
73  ${PHASTA_COMMON_LIBS}
74  incompressible
75  ${LESLIB}
76  incompressible
77  ${PHASTA_COMMON_LIBS}
78)
79
80else(PHASTA_USE_SVLS)
81message(STATUS "using SVLS")
82set(PHASTAIC_LIBS
83  ${PHASTA_COMMON_LIBS}
84  incompressible
85  svLS
86  incompressible
87  ${PHASTA_COMMON_LIBS}
88)
89endif()
90
91set(PHASTAIC_LIBS ${PHASTAIC_LIBS} phastaIO)
92if(PHASTA_BUILD_SHAPEFUNCTION)
93  set(PHASTAIC_LIBS ${PHASTAIC_LIBS} shapeFunction)
94endif(PHASTA_BUILD_SHAPEFUNCTION)
95if(PHASTA_BUILD_PHSHAPE)
96  set(PHASTAIC_LIBS ${PHASTAIC_LIBS} phshape)
97endif(PHASTA_BUILD_PHSHAPE)
98target_link_libraries(phastaIC.exe ${PHASTAIC_LIBS})
99if(PHASTA_USE_PETSC)
100	#target_link_libraries(phastaC.exe ${PETSC_LIB}/libpetsc.a ${PETSC_PACKAGE_LIBS})
101	target_link_libraries(phastaIC.exe petsc ${PETSC_PACKAGE_LIBS} ${PHASTAIC_LIBS})
102endif()
103configure_file(
104  "${CMAKE_CURRENT_SOURCE_DIR}/phastaICConfig.cmake.in"
105  "${CMAKE_BINARY_DIR}/phastaICConfig.cmake"
106)
107
108if(PHASTA_TESTING)
109  add_subdirectory(test)
110endif(PHASTA_TESTING)
111