Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake 3.3.2 #16

Open
jacopo-chevallard opened this issue Apr 15, 2016 · 13 comments
Open

CMake 3.3.2 #16

jacopo-chevallard opened this issue Apr 15, 2016 · 13 comments

Comments

@jacopo-chevallard
Copy link

I'm having troubles in compiling FPL with CMake 3.3.2 on a Mac OS X (with GCC 5.2)

If I run cmake .. from my build directory I get

-- The Fortran compiler identification is GNU 5.2.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Check for working Fortran compiler: /usr/local/bin/gfortran-5
-- Check for working Fortran compiler: /usr/local/bin/gfortran-5  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/local/bin/gfortran-5 supports Fortran 90
-- Checking whether /usr/local/bin/gfortran-5 supports Fortran 90 -- yes
-- COMPILER INFO: GNU - gfortran-5
-- CMAKE_Fortran_COMPILER full path: /usr/local/bin/gfortran-5
-- CMAKE_Fortran_FLAGS: -fdefault-real-8 -ffree-line-length-0 -cpp -Wimplicit-interface
-- CMAKE_Fortran_FLAGS_RELEASE: -O3
-- CMAKE_Fortran_FLAGS_DEBUG: -g -fbacktrace -fbounds-check -fprofile-arcs -ftest-coverage -Wimplicit-interface
CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Test" because another
  target with the same name already exists.  The existing target is an
  executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Wrapper0D_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Wrapper1D_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Wrapper2D_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Wrapper3D_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Wrapper4D_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Wrapper5D_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Wrapper6D_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "ParameterList_Wrapper7D_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "WrapperFactoryList_DLCA_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "WrapperFactoryList_I1P_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "WrapperFactoryList_I2P_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "WrapperFactoryList_I4P_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "WrapperFactoryList_I8P_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "WrapperFactoryList_L_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "WrapperFactoryList_R4P_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/tests/CMakeLists.txt:14 (ADD_EXECUTABLE):
  add_executable cannot create target "WrapperFactoryList_R8P_Test" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/tests".  See documentation for
  policy CMP0002 for more details.


CMake Error at src/examples/CMakeLists.txt:11 (ADD_EXECUTABLE):
  add_executable cannot create target "FortranParameterList_Example" because
  another target with the same name already exists.  The existing target is
  an executable created in source directory
  "/Users/jchevall/Coding/External/FPL/src/examples".  See documentation for
  policy CMP0002 for more details.


-- Configuring incomplete, errors occurred!
See also "/Users/jchevall/Coding/External/FPL/build/CMakeFiles/CMakeOutput.log".

Any idea?

@victorsndvg
Copy link
Owner

Hi @jacopo-chevallard ,

sorry, but I was not aware of the FPL issues...

Currently I'm using CMAKE 3.2.3. I'm going to download and try to reproduce your issue.

Thanks for reporting it! 👍

@victorsndvg
Copy link
Owner

@jacopo-chevallard I have tried with CMake 3.5.2 and it works fine for me.

In the CMakeLists.txt file in the test folder, I build the test target names from the test filenames. It seems that CMake is telling you that you are trying to create more than 1 test with the same name and, in the case of FPL, it only occurs if some files have the same name (????).

I have experienced that temporary emacs files (.#filename.f90) can be understood like "valid" sources for the test targets and cause this kind of problems.

Please, check that your tests folders does not contain any extra file before the CMake configure step.

I have to think how can I fix this...

Let me know if it works for you! :)

@jacopo-chevallard
Copy link
Author

Sorry, I had lost track of this issue. In the end, I commented out from CMake the compilation of the tests, and just built the library.

I confirm, however, that even after updating to CMake 3.5.2 I get the same error. I just tried the following commands

git clone https://github.com/victorsndvg/FPL.git
cd FPL
mkdir build 
cd build
cmake ..

and obtained again the errors reported above.

@victorsndvg victorsndvg reopened this May 20, 2016
@victorsndvg
Copy link
Owner

Hi @jacopo-chevallard

first of all, the git command to clone that you have to use to also clone submodules is:
git clone --recursive https://github.com/victorsndvg/FPL.git

Are you sure that you don't have extra files in tests folder? If not, I cannot understand the error...

Sorry, but I'm not able to reproduce the error you are reporting ... it compiles as expected for me using different versions of CMake.

@jacopo-chevallard
Copy link
Author

Are you also testing on a Mac OS X?
The --recursive option doesn't solve either...

@victorsndvg
Copy link
Owner

No, sorry I don't have access to Mac OS X.

I will be very grateful if you could tell me what happens if you try to change ${EXE_NAME} by {TEST_SRC} in the following file/line:
https://github.com/victorsndvg/FPL/blob/master/src/tests/CMakeLists.txt#L14

It could help to understand what files are in conflict.

@jacopo-chevallard
Copy link
Author

If i replace EXE_NAME by TEST_SRC i get the error

CMake Error at src/tests/CMakeLists.txt:15 (TARGET_LINK_LIBRARIES):
  Cannot specify link libraries for target "ParameterList_Test" which is not
  built by this project.

@victorsndvg
Copy link
Owner

Yes ... of course ... it was my fault, sorry.

This is a valid (for me) CMakeLists.txt for src/tests/ folder:

#################################################################
# TESTS
#################################################################

FILE(GLOB_RECURSE TESTS_SRC *.f90 *.F90)
SET(TESTS_SRC ${TESTS_SRC} PARENT_SCOPE)

#################################################################
# EXTERNAL LIBRARIES
#################################################################

FOREACH(TEST_SRC ${TESTS_SRC})
    GET_FILENAME_COMPONENT(EXE_NAME ${TEST_SRC} NAME_WE)
    GET_FILENAME_COMPONENT(FILE_EXT ${TEST_SRC} EXT)
    SET(EXE_NAME "${EXE_NAME}${FILE_EXT}")
    ADD_EXECUTABLE(${EXE_NAME} ${TEST_SRC})
    TARGET_LINK_LIBRARIES(${EXE_NAME} ${LIB})
    FOREACH (EXT_LIB ${EXT_LIBS})
        IF(DEFINED ${PROJECT_NAME}_ENABLE_${EXT_LIB} AND ${PROJECT_NAME}_ENABLE_${EXT_LIB} AND ${EXT_LIB}_FOUND)
            TARGET_LINK_LIBRARIES(${EXE_NAME} ${${EXT_LIB}_LIBRARIES})
        ENDIF()
    ENDFOREACH()

    ADD_TEST(${EXE_NAME}_TEST ${EXECUTABLE_OUTPUT_PATH}/${EXE_NAME})
ENDFOREACH()

@jacopo-chevallard
Copy link
Author

I still get the same errors with the above CMakeLists.txt

@victorsndvg
Copy link
Owner

Ok, sorry. I need to get access to Mac OS X to try what is happening by myself...

I think that the best (temporal) option now is to create an option in the main CMakeListst.txt to decide if the user want to compile test or not. By default tests will not be compiled

It's ok for you?

@jacopo-chevallard
Copy link
Author

Sure, this is what I did manually, by removing the compilation of the tests.

In any case, this is a wonderful module, definitely the nearest thing to a Python dictionary for Fortran that I've seen around, I'm using it extensively in my codes, for instance to pass the equivalent of **kwargs to routines. Great job! :)

@victorsndvg
Copy link
Owner

Thanks, you are so kind! :)

Let me know any suggestion to improve FPL!

victorsndvg pushed a commit that referenced this issue May 23, 2016
use:

cmake -DFPL_ENABLE_TESTS=ON -DFPL_ENABLE_EXAMPLES=ON $SOURCE_DIR

First aproach (but not a real solution) to solve issue #16
victorsndvg pushed a commit that referenced this issue May 23, 2016
    use:

    cmake -DFPL_ENABLE_TESTS=ON -DFPL_ENABLE_EXAMPLES=ON $SOURCE_DIR

    First aproach (but not a real solution) to solve issue #16
@victorsndvg
Copy link
Owner

Hi @jacopo-chevallard ,

I still without understanding the problem ...

But I've read that if you add cmake_policy(SET CMP0002 OLD) after CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7) into the main CMakeLists.txt file, it will allow you to compile tests and examples.

victorsndvg pushed a commit that referenced this issue Jun 13, 2016
    use:

    cmake -DFPL_ENABLE_TESTS=ON -DFPL_ENABLE_EXAMPLES=ON $SOURCE_DIR

    First aproach (but not a real solution) to solve issue #16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants