1. Lisandro Dalcin
  2. PetIGA

Commits

Lisandro Dalcin  committed 4961a31

Add CMake support for C++ builds

  • Participants
  • Parent commits 0bd4b51
  • Branches default

Comments (0)

Files changed (2)

File CMakeLists.txt

View file
   include (${PETSC_DIR}/${PETSC_ARCH}/conf/PETScConfig.cmake)
 endif()
 
-#set (BUILD_SHARED_LIBS NO)
-
+if (PETSC_CLANGUAGE_Cxx)
+  enable_language (CXX)
+endif ()
 enable_language (Fortran)
 
 include_directories (${PETSC_INCLUDES} ${PETSC_PACKAGE_INCLUDES}
 add_library (petiga ${PetIGA_SOURCES_ALL})
 target_link_libraries (petiga ${PETSC_LIBRARIES} ${PETSC_PACKAGE_LIBS})
 
+if (PETSC_CLANGUAGE_Cxx)
+  foreach (file ${PetIGA_SOURCES_C})
+    set_source_files_properties(${file} PROPERTIES LANGUAGE CXX)
+  endforeach ()
+endif ()
+
+#set (BUILD_SHARED_LIBS NO)
+
 #if (BUILD_SHARED_LIBS)
 #  add_library (petiga-static STATIC ${PetIGA_SOURCES_ALL})
 #  set_target_properties (petiga-static PROPERTIES OUTPUT_NAME "petiga")

File makefile

View file
 #
 # CMake build
 #
-cmake_cc=-DCMAKE_C_COMPILER:FILEPATH=${PCC} -DCMAKE_C_FLAGS:STRING='${PCC_FLAGS} ${CFLAGS} ${PETSCFLAGS} ${CPP_FLAGS} ${CPPFLAGS}'
-cmake_fc=-DCMAKE_Fortran_COMPILER:FILEPATH=${FC} -DCMAKE_Fortran_FLAGS:STRING='${FC_FLAGS} ${FFLAGS} ${PETSCFLAGS} ${FPP_FLAGS} ${FPPFLAGS}'
+ifeq (${PETSC_LANGUAGE},CXXONLY)
+cmake_cc_clang=-DPETSC_CLANGUAGE_Cxx:STRING='YES'
+cmake_cc_path =-DCMAKE_CXX_COMPILER:FILEPATH=${CXX}
+cmake_cc_flags=-DCMAKE_CXX_FLAGS:STRING='${PCC_FLAGS} ${CFLAGS} ${PETSCFLAGS} ${CPP_FLAGS} ${CPPFLAGS}'
+else
+cmake_cc_clang=-DPETSC_CLANGUAGE_Cxx:STRING='NO'
+cmake_cc_path =-DCMAKE_C_COMPILER:FILEPATH=${CC}
+cmake_cc_flags=-DCMAKE_C_FLAGS:STRING='${PCC_FLAGS} ${CFLAGS} ${PETSCFLAGS} ${CPP_FLAGS} ${CPPFLAGS}'
+endif
+cmake_fc_path =-DCMAKE_Fortran_COMPILER:FILEPATH=${FC}
+cmake_fc_flags=-DCMAKE_Fortran_FLAGS:STRING='${FC_FLAGS} ${FFLAGS} ${PETSCFLAGS} ${FPP_FLAGS} ${FPPFLAGS}'
+cmake_cc=${cmake_cc_path} ${cmake_cc_flags} ${cmake_cc_clang}
+cmake_fc=${cmake_fc_path} ${cmake_fc_flags}
 ${PETIGA_DIR}/${PETSC_ARCH}/conf:
 	@${MKDIR} ${PETIGA_DIR}/${PETSC_ARCH}/conf
 ${PETIGA_DIR}/${PETSC_ARCH}/CMakeCache.txt: ${PETIGA_DIR}/${PETSC_ARCH}/conf