v0.14.0
PrecompileHeaders.cmake
Go to the documentation of this file.
1 #
2 
3 include_directories(${PROJECT_SOURCE_DIR}/basic_finite_elements/src)
4 
5 if(MoFEM_PRECOMPILED_HEADRES)
6 
7  if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
8  set(OUT_PCH_SUFFIX "pch")
9  elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
10  set(OUT_PCH_SUFFIX "gch")
11  endif()
12 
13  # BasicFiniteElements.hpp
14  set_source_files_properties(
15  ${PROJECT_SOURCE_DIR}/basic_finite_elements/src/BasicFiniteElements.hpp
16  PROPERTIES
17  LANGUAGE CXX
18  COMPILE_FLAGS "-x c++-header"
19  )
20  add_library(
21  BasicFiniteElements.hpp.pch
22  OBJECT
23  ${PROJECT_SOURCE_DIR}/basic_finite_elements/src/BasicFiniteElements.hpp
24  )
25  add_custom_target(
26  BasicFiniteElements.hpp.pch_copy
27  ${CMAKE_COMMAND} -E copy_if_different
28  ${PROJECT_BINARY_DIR}/CMakeFiles/BasicFiniteElements.hpp.pch.dir/basic_finite_elements/src/BasicFiniteElements.hpp.o
29  ${PROJECT_BINARY_DIR}/basic_finite_elements/src/precompile/BasicFiniteElements.hpp.${OUT_PCH_SUFFIX}
30  COMMAND
31  ${CMAKE_COMMAND} -E copy_if_different
32  ${PROJECT_SOURCE_DIR}/basic_finite_elements/src/BasicFiniteElements.hpp
33  ${PROJECT_BINARY_DIR}/basic_finite_elements/src/precompile/BasicFiniteElements.hpp
34  COMMENT
35  "Copy precompiled BasicFiniteElements.hpp header"
36  )
37  add_dependencies(BasicFiniteElements.hpp.pch_copy BasicFiniteElements.hpp.pch)
38 
39 endif(MoFEM_PRECOMPILED_HEADRES)
40 
41 set(PERCOMPILED_HEADER
42  ${PROJECT_BINARY_DIR}/basic_finite_elements/src/precompile/BasicFiniteElements.hpp)
43 
44 function(bfe_add_executable target source)
45  if(MoFEM_PRECOMPILED_HEADRES)
46  set_source_files_properties(${source} PROPERTIES COMPILE_FLAGS "-include ${PERCOMPILED_HEADER}")
47  endif(MoFEM_PRECOMPILED_HEADRES)
48  add_executable(${target} ${source})
49  if(MoFEM_PRECOMPILED_HEADRES)
50  add_dependencies(${target} BasicFiniteElements.hpp.pch_copy)
51  endif(MoFEM_PRECOMPILED_HEADRES)
52 endfunction(bfe_add_executable)
53 
54