New cmake porject issues

53 views
Skip to first unread message

Kristoffer Lindvall

unread,
Jun 2, 2022, 8:36:48 AM6/2/22
to deal.II User Group
Hey!

I have tried to make a new cmake project with the current cmakelist text file

SET(TARGET "kfli")

SET(TARGET_SRC
  kfli.cc
)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)

FIND_PACKAGE(deal.II 9.3.3 QUIET
  HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
  )
IF(NOT ${deal.II_FOUND})
  MESSAGE(FATAL_ERROR "\n"
    "*** Could not locate a (sufficiently recent) version of deal.II. ***\n\n"
    "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n"
    "or set an environment variable \"DEAL_II_DIR\" that contains this path."
    )
ENDIF()

#
# Are all dependencies fulfilled?
#
IF(NOT DEAL_II_WITH_TRILINOS)
  MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
    DEAL_II_WITH_TRILINOS = ON
One or all of these are OFF in your installation but are required for this tutorial step."
    )
ENDIF()

DEAL_II_INITIALIZE_CACHED_VARIABLES()
PROJECT(${TARGET})
IF(WIN32)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG")
    IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od /MP")
    ELSE()
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ob2 /Oi /Ot /GL /MP")
    ENDIF()
ELSE()
    IF(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug"))
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
    ENDIF()
ENDIF()
include_directories(${DEAL_II_INCLUDE_DIRS})
add_library(${TARGET} ${TARGET_SRC})
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
DEAL_II_SETUP_TARGET(${TARGET} DEBUG)
ELSE()
DEAL_II_SETUP_TARGET(${TARGET} RELEASE)
ENDIF()
add_subdirectory(examples)
install(TARGETS ${TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)


When I run this with

cmake -DDEAL_II_DIR=~/deal.II -DDEAL_II_WITH_MPI=ON -DDEAL_II_WITH_TRILINOS=ON -DTRILINOS_DIR=/home/shoopawax/spack/opt/spack/linux-ubuntu22.04-zen2/gcc-11.2.0/trilinos-13.0.1-wa34uf3ac22ppigikuf65nykw73zoovs -DDEAL_II_WITH_P4EST=ON -DP4EST_DIR=/home/shoopawax/spack/opt/spack/linux-ubuntu22.04-zen2/gcc-11.2.0/p4est-2.8-h3wrhiw7p5snzhhcnmplwmwmekpynkfo -DCMAKE_INSTALL_PREFIX=~/deal.II ~/dealii-9.3.3/

The whole deal.ii library is built from scratch and a bunch of folders like lib, doc, examples, bin, bundles, etc. I don't know what I'm doing wrong. I copied the cmakelist text from another project on github and that project runs without building from scratch or multiple folders. What am I doing wrong?

Best regards,
Kristoffer

Kristoffer Lindvall

unread,
Jun 2, 2022, 11:07:45 AM6/2/22
to deal.II User Group
The answer was to only run: cmake -DDEAL_II_DIR=~/deal.II .

Wolfgang Bangerth

unread,
Jun 2, 2022, 1:34:33 PM6/2/22
to dea...@googlegroups.com
On 6/2/22 06:36, Kristoffer Lindvall wrote:
>
> cmake -DDEAL_II_DIR=~/deal.II -DDEAL_II_WITH_MPI=ON
> -DDEAL_II_WITH_TRILINOS=ON
> -DTRILINOS_DIR=/home/shoopawax/spack/opt/spack/linux-ubuntu22.04-zen2/gcc-11.2.0/trilinos-13.0.1-wa34uf3ac22ppigikuf65nykw73zoovs
> -DDEAL_II_WITH_P4EST=ON
> -DP4EST_DIR=/home/shoopawax/spack/opt/spack/linux-ubuntu22.04-zen2/gcc-11.2.0/p4est-2.8-h3wrhiw7p5snzhhcnmplwmwmekpynkfo
> -DCMAKE_INSTALL_PREFIX=~/deal.II ~/dealii-9.3.3/

Your mistake is with that last argument. An argument without preceding
-D is considered a source directory. So you're saying that you want the
source directory to be ~/dealii-9.3.3. That's not what you want. As you
found out in your later mail, you want the source directory to be the
one you're currently in, that is ".".

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/
Reply all
Reply to author
Forward
0 new messages