Skip to content

CMake Error: Duplicate Target Names in example/CMakeLists.txt #10

@syoukera

Description

@syoukera

Description:
I encountered a build error when compiling TCHEM inside a Docker container. The issue appears to be related to duplicate target names in example/CMakeLists.txt, causing ADD_EXECUTABLE to fail due to already existing targets.

Environment:
Kokkos Version: v3.7.0
Tines Version: tines-kokkosv4
TCHEM Version: tchem-kokkosv4
Compiler: GCC (default in Docker image)
Build System: CMake

Steps to Reproduce:
Use the following Dockerfile (attached) to build TCHEM.
Run docker build -t tchem-image .
The following error occurs during configuration:

$ docker build -t tchem-image .
[+] Building 57.6s (18/19)                                                  docker:default
 => [internal] load build definition from dockerfile                                  0.0s
 => => transferring dockerfile: 4.59kB                                                0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04                       0.8s
 => [internal] load .dockerignore                                                     0.0s
 => => transferring context: 2B                                                       0.0s
 => [ 1/16] FROM docker.io/library/ubuntu:20.04@sha256:8e5c4f0285ecbb4ead070431d29b5  0.0s
 => => resolve docker.io/library/ubuntu:20.04@sha256:8e5c4f0285ecbb4ead070431d29b576  0.0s
 => CACHED [ 2/16] RUN apt-get update && apt-get install -y     build-essential cmak  0.0s
 => CACHED [ 3/16] RUN mkdir -p /repos /build /install                                0.0s
 => CACHED [ 4/16] WORKDIR /repos                                                     0.0s
 => CACHED [ 5/16] RUN git clone https://github.com/xianyi/OpenBLAS.git /repos/openb  0.0s
 => CACHED [ 6/16] WORKDIR /repos                                                     0.0s
 => [ 7/16] RUN git clone https://github.com/kokkos/kokkos /repos/kokkos &&     cd   12.3s
 => [ 8/16] WORKDIR /repos                                                            0.0s
 => [ 9/16] RUN git clone https://github.com/google/googletest.git /repos/gtest &&    6.4s
 => [10/16] WORKDIR /repos                                                            0.0s
 => [11/16] RUN git clone -b yaml-cpp-0.6.3 https://github.com/jbeder/yaml-cpp.git   27.2s
 => [12/16] WORKDIR /repos                                                            0.0s
 => [13/16] RUN git clone https://github.com/sandialabs/Tines /repos/tines &&     cd  7.0s
 => [14/16] WORKDIR /repos                                                            0.0s
 => ERROR [15/16] RUN git clone https://github.com/sandialabs/TChem /repos/tchem &&   3.6s
------
 > [15/16] RUN git clone https://github.com/sandialabs/TChem /repos/tchem &&     cd /repos/tchem &&     git checkout tchem-kokkosv4.2 &&     mkdir /build/tchem &&     mkdir /install/tchem &&     cd /build/tchem &&     cmake -D CMAKE_INSTALL_PREFIX=/install/tchem           -D CMAKE_CXX_COMPILER=g++           -D CMAKE_C_COMPILER=gcc           -D CMAKE_EXE_LINKER_FLAGS="-lgfortran"           -D TCHEM_ENABLE_TEST=ON           -D TCHEM_ENABLE_EXAMPLE=ON           -D KOKKOS_INSTALL_PATH=/install/kokkos           -D TINES_INSTALL_PATH=/install/tines           -D GTEST_INSTALL_PATH=/install/gtest           /repos/tchem/src &&     make -j$(nproc) install:
0.326 Cloning into '/repos/tchem'...
3.012 Switched to a new branch 'tchem-kokkosv4.2'
3.012 Branch 'tchem-kokkosv4.2' set up to track remote branch 'tchem-kokkosv4.2' from 'origin'.
3.041 -- The C compiler identification is GNU 9.4.0
3.066 -- The CXX compiler identification is GNU 9.4.0
3.068 -- Check for working C compiler: /usr/bin/gcc
3.101 -- Check for working C compiler: /usr/bin/gcc -- works
3.101 -- Detecting C compiler ABI info
3.134 -- Detecting C compiler ABI info - done
3.140 -- Detecting C compile features
3.140 -- Detecting C compile features - done
3.141 -- Check for working CXX compiler: /usr/bin/g++
3.178 -- Check for working CXX compiler: /usr/bin/g++ -- works
3.179 -- Detecting CXX compiler ABI info
3.216 -- Detecting CXX compiler ABI info - done
3.222 -- Detecting CXX compile features
3.222 -- Detecting CXX compile features - done
3.226 -- CMAKE_INSTALL_LIBDIR is set lib
3.226 -- TChem uses real type DOUBLE PRECISION
3.226 -- TChem Main executable is enabled and it looks for Boost library
3.228 -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0")
3.229 -- Boost version: 1.71.0
3.229 -- Boost include: /usr/include
3.229 -- Boost library:
3.229 -- TChem attempts to use Kokkos installed at /install/kokkos
3.231 -- Kokkos install path : /install/kokkos
3.231 -- Kokkos found cmake config : /install/kokkos/lib/cmake/Kokkos/KokkosConfig.cmake
3.345 -- Found OpenMP_C: -fopenmp (found version "4.5")
3.385 -- Found OpenMP_CXX: -fopenmp (found version "4.5")
3.385 -- Found OpenMP: TRUE (found version "4.5")
3.386 -- Enabled Kokkos devices: OPENMP;SERIAL
3.386 -- TChem attempts to use Tines installed at /install/tines
3.387 -- Tines install path : /install/tines
3.387 -- Tines found cmake config : /install/tines/lib/cmake/Tines/TinesConfig.cmake
3.388 -- TChem uses gtest installed at /install/gtest
3.388 -- Gtest install path : /install/gtest
3.388 -- Gtest found cmake config : /install/gtest/lib/cmake/GTest/GTestConfig.cmake
3.388 -- Looking for pthread.h
3.421 -- Looking for pthread.h - found
3.421 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
3.457 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
3.457 -- Looking for pthread_create in pthreads
3.486 -- Looking for pthread_create in pthreads - not found
3.486 -- Looking for pthread_create in pthread
3.518 -- Looking for pthread_create in pthread - found
3.519 -- Found Threads: TRUE
3.519 -- TCHEM_LINK_LIBRARIES = tchem;Kokkos::kokkos;Tines::tines;GTest::gtest_main
3.520 -- Generating ETI: TChem_IgnitionZeroD_SacadoJacobian_Host_SLFad_16.cpp
3.520 -- Generating ETI: TChem_IgnitionZeroD_SacadoJacobian_Host_SLFad_32.cpp
3.520 -- Generating ETI: TChem_IgnitionZeroD_SacadoJacobian_Host_SLFad_64.cpp
3.521 -- Generating ETI: TChem_IgnitionZeroD_SacadoJacobian_Host_SLFad_128.cpp
3.521 -- Generating ETI: TChem_IgnitionZeroD_SacadoJacobian_Host_SLFad_256.cpp
3.521 -- Generating ETI: TChem_IgnitionZeroD_SacadoJacobian_Host_SLFad_512.cpp
3.521 -- Generating ETI: TChem_IgnitionZeroD_SacadoJacobian_Host_SLFad_1024.cpp
3.521 -- Generating ETI: TChem_TransientContStirredTankReactorSacadoJacobian_Host_SLFad_16.cpp
3.521 -- Generating ETI: TChem_TransientContStirredTankReactorSacadoJacobian_Host_SLFad_32.cpp
3.521 -- Generating ETI: TChem_TransientContStirredTankReactorSacadoJacobian_Host_SLFad_64.cpp
3.521 -- Generating ETI: TChem_TransientContStirredTankReactorSacadoJacobian_Host_SLFad_128.cpp
3.521 -- Generating ETI: TChem_TransientContStirredTankReactorSacadoJacobian_Host_SLFad_256.cpp
3.521 -- Generating ETI: TChem_TransientContStirredTankReactorSacadoJacobian_Host_SLFad_512.cpp
3.521 -- Generating ETI: TChem_TransientContStirredTankReactorSacadoJacobian_Host_SLFad_1024.cpp
3.522 -- Generating ETI: TChem_IsothermalTransientContStirredTankReactorSacadoJacobian_Host_SLFad_16.cpp
3.522 -- Generating ETI: TChem_IsothermalTransientContStirredTankReactorSacadoJacobian_Host_SLFad_32.cpp
3.522 -- Generating ETI: TChem_IsothermalTransientContStirredTankReactorSacadoJacobian_Host_SLFad_64.cpp
3.522 -- Generating ETI: TChem_IsothermalTransientContStirredTankReactorSacadoJacobian_Host_SLFad_128.cpp
3.522 -- Generating ETI: TChem_IsothermalTransientContStirredTankReactorSacadoJacobian_Host_SLFad_256.cpp
3.522 -- Generating ETI: TChem_IsothermalTransientContStirredTankReactorSacadoJacobian_Host_SLFad_512.cpp
3.522 -- Generating ETI: TChem_IsothermalTransientContStirredTankReactorSacadoJacobian_Host_SLFad_1024.cpp
3.522 -- Generating ETI: TChem_PlugFlowReactorSacadoJacobian_Host_SLFad_16.cpp
3.522 -- Generating ETI: TChem_PlugFlowReactorSacadoJacobian_Host_SLFad_32.cpp
3.522 -- Generating ETI: TChem_PlugFlowReactorSacadoJacobian_Host_SLFad_64.cpp
3.522 -- Generating ETI: TChem_PlugFlowReactorSacadoJacobian_Host_SLFad_128.cpp
3.522 -- Generating ETI: TChem_PlugFlowReactorSacadoJacobian_Host_SLFad_256.cpp
3.523 -- Generating ETI: TChem_PlugFlowReactorSacadoJacobian_Host_SLFad_512.cpp
3.523 -- Generating ETI: TChem_PlugFlowReactorSacadoJacobian_Host_SLFad_1024.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_Host_SLFad_16.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_Host_SLFad_32.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_Host_SLFad_64.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_Host_SLFad_128.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_Host_SLFad_256.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_Host_SLFad_512.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_Host_SLFad_1024.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_Host_Scalar.cpp
3.523 -- Generating ETI: TChem_IgnitionZeroD_CVODE_Host_Scalar.cpp
3.533 CMake Error at example/CMakeLists.txt:102 (ADD_EXECUTABLE):
3.533   ADD_EXECUTABLE cannot create target "TCHEM_EXAMPLE_MACRO" because another
3.533   target with the same name already exists.  The existing target is an
3.533   executable created in source directory "/repos/tchem/src/example".  See
3.533   documentation for policy CMP0002 for more details.
3.533
3.533
3.533 CMake Error at example/CMakeLists.txt:102 (ADD_EXECUTABLE):
3.533   ADD_EXECUTABLE cannot create target "IN" because another target with the
3.533   same name already exists.  The existing target is an executable created in
3.533   source directory "/repos/tchem/src/example".  See documentation for policy
3.533   CMP0002 for more details.
3.533
3.533
3.533 CMake Error at example/CMakeLists.txt:102 (ADD_EXECUTABLE):
3.533   ADD_EXECUTABLE cannot create target "ZIP_LISTS" because another target with
3.533   the same name already exists.  The existing target is an executable created
3.533   in source directory "/repos/tchem/src/example".  See documentation for
3.533   policy CMP0002 for more details.
3.533
3.533
3.534 CMake Error at example/CMakeLists.txt:102 (ADD_EXECUTABLE):
3.534   ADD_EXECUTABLE cannot create target "TCHEM_EXAMPLE_EXES" because another
3.534   target with the same name already exists.  The existing target is an
3.534   executable created in source directory "/repos/tchem/src/example".  See
3.534   documentation for policy CMP0002 for more details.
3.534
3.534
3.534 CMake Error at example/CMakeLists.txt:102 (ADD_EXECUTABLE):
3.534   ADD_EXECUTABLE cannot create target "TCHEM_EXAMPLE_MACROS" because another
3.534   target with the same name already exists.  The existing target is an
3.534   executable created in source directory "/repos/tchem/src/example".  See
3.534   documentation for policy CMP0002 for more details.
3.534
3.534
3.572 -- Configuring incomplete, errors occurred!
3.572 See also "/build/tchem/CMakeFiles/CMakeOutput.log".
3.572 See also "/build/tchem/CMakeFiles/CMakeError.log".
------
dockerfile:101
--------------------
 100 |     WORKDIR ${REPO_BASE}
 101 | >>> RUN git clone https://github.com/sandialabs/TChem ${TCHEM_REPOSITORY_PATH} && \
 102 | >>>     cd ${TCHEM_REPOSITORY_PATH} && \
 103 | >>>     git checkout tchem-kokkosv4.2 && \
 104 | >>>     mkdir ${TCHEM_BUILD_PATH} && \
 105 | >>>     mkdir ${TCHEM_INSTALL_PATH} && \
 106 | >>>     cd ${TCHEM_BUILD_PATH} && \
 107 | >>>     cmake -D CMAKE_INSTALL_PREFIX=${TCHEM_INSTALL_PATH} \
 108 | >>>           -D CMAKE_CXX_COMPILER=g++ \
 109 | >>>           -D CMAKE_C_COMPILER=gcc \
 110 | >>>           -D CMAKE_EXE_LINKER_FLAGS="-lgfortran" \
 111 | >>>           -D TCHEM_ENABLE_TEST=ON \
 112 | >>>           -D TCHEM_ENABLE_EXAMPLE=ON \
 113 | >>>           -D KOKKOS_INSTALL_PATH=${KOKKOS_INSTALL_PATH} \
 114 | >>>           -D TINES_INSTALL_PATH=${TINES_INSTALL_PATH} \
 115 | >>>           -D GTEST_INSTALL_PATH=${GTEST_INSTALL_PATH} \
 116 | >>>           ${TCHEM_REPOSITORY_PATH}/src && \
 117 | >>>     make -j$(nproc) install
 118 |
--------------------
ERROR: failed to solve: process "/bin/sh -c git clone https://github.com/sandialabs/TChem ${TCHEM_REPOSITORY_PATH} &&     cd ${TCHEM_REPOSITORY_PATH} &&     git checkout tchem-kokkosv4.2 &&     mkdir ${TCHEM_BUILD_PATH} &&     mkdir ${TCHEM_INSTALL_PATH} &&     cd ${TCHEM_BUILD_PATH} &&     cmake -D CMAKE_INSTALL_PREFIX=${TCHEM_INSTALL_PATH}           -D CMAKE_CXX_COMPILER=g++           -D CMAKE_C_COMPILER=gcc           -D CMAKE_EXE_LINKER_FLAGS=\"-lgfortran\"           -D TCHEM_ENABLE_TEST=ON           -D TCHEM_ENABLE_EXAMPLE=ON           -D KOKKOS_INSTALL_PATH=${KOKKOS_INSTALL_PATH}           -D TINES_INSTALL_PATH=${TINES_INSTALL_PATH}           -D GTEST_INSTALL_PATH=${GTEST_INSTALL_PATH}           ${TCHEM_REPOSITORY_PATH}/src &&     make -j$(nproc) install" did not complete successfully: exit code: 1

Additional similar errors appear for multiple targets like IN, ZIP_LISTS, TCHEM_EXAMPLE_EXES, and TCHEM_EXAMPLE_MACROS.

Expected Behavior:
CMake should generate the build system without conflicting target names, allowing successful compilation of TCHEM.

Observed Behavior:
CMake fails due to duplicate target names in example/CMakeLists.txt.

Attachments:
Dockerfile used for building TCHEM.

Could you please provide guidance on how to resolve this issue?
Thank you in advance for your support!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions