pthom/clion-ninja

Problems with CLion 2017.1.1

armarkos opened this issue · 2 comments

Hello,

Thanks for the script. Somehow I could not make it work. This is the command CLion 2017.1.1 tries to run: (I use macports' CMake /opt/local/bin/cmake)

cmake_ninja_wrapper.py -DCMAKE_BUILD_TYPE=Debug -DTrilinos_INSTALL_DIR=/Trilinos_mpi -DCMAKE_CXX_COMPILER=/opt/local/bin/mpic++-mpich-clang39 -DCMAKE_C_COMPILER=/opt/local/bin/mpicc-mpich-clang39 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE:BOOL=on -GNinja -DCMAKE_MAKE_PROGRAM=/opt/local/bin/ninja -G "CodeBlocks - Unix Makefiles" ..

And it outputs:

-- The CXX compiler identification is Clang 3.9.1
-- Check for working C compiler: /opt/local/bin/mpicc-mpich-clang39
-- Check for working C compiler: /opt/local/bin/mpicc-mpich-clang39 -- broken
CMake Error at /opt/local/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
  The C compiler "/opt/local/bin/mpicc-mpich-clang39" is not able to compile
  a simple test program.

  It fails with the following output:

   Change Dir: /Users/..../tests/CMakeFiles/CMakeTmp

  Run Build Command:"/opt/local/bin/ninja" "cmTC_b6488/fast"

  ninja: error: loading 'build.ninja': No such file or directory

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:14 (PROJECT)


-- Configuring incomplete, errors occurred!
See also "/Users/..../tests/CMakeFiles/CMakeOutput.log".
See also "/Users/.../tests/CMakeFiles/CMakeError.log".```

Do you know what is going on? I can run CMake&ninja outside of CLion fine, but not inside.

Thanks,
Aram

pthom commented

Hum, you might need to tweak the script a little bit : I confirmed that it works under OSX, but not linux.
Maybe you should try to debug the script using a python debugger (pycharm is excellent, easy and free).

See the extract below : normally, ninjafy_argv should have replaced -G "CodeBlocks - Unix Makefiles" by "-GNinja" and it did not

def ninjafy_argv(original):
    """Replace Unix Makefiles generator with Ninja"""
    found = False
    foundG = False
    processed = []
    next_g = False
    for a in original:
        if a == '-G':
            next_g = True
            foundG = True
        elif next_g and 'Unix Makefiles' in a:
            #a = a.replace('CodeBlocks - Unix Makefiles', 'Ninja')
            a = "Ninja"
            next_g = False
            found = True
        processed.append(a)
    trace("ninjafy_argv => found = " + str(found) + " FoundG=" + str(foundG))
    return processed

Hi and thanks for quick reply.

I was doing something stupid in Clion, I was passing "-GNinja" and as a result your script was getting both "-GNinja" and "-G "CodeBlocks - Unix Makefiles" " :)

Everything is fine now!

Thanks again,
Aram