2

I have a project which was previously linux only in makefile.

I have successfully migrated it to cmake and that works fine, it compiles in pure linux (makefile --> so) and pure windows (visual studio --> dll) with no issue. It also compiles fine on linux for windows (using mingw --> dll).

However, for integration and script compatibility issues, I have to generate and build the code for windows (dll) but on a cygwin environment (with cygwin's gcc providing a dll), like the old makefile used to do. (I have to do this way, due to external constraints)

I have installed both "make" and "cmake" packages on my cygwin.

When I try to generate a makefile in the cygwin console, it gets stuck:

$ cmake -G "Unix Makefiles" ../Sources
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
[ -- stuck - nothing happens here -- ]

When I stop it (ctrl-C), it says nothing and the "Makefile" file is present in my build directory, so I try and compile it:

$ make
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
[ -- stuck - nothing happens here -- ]

It seems to be re-generating all all over again (I get my cmake prints again, the Makefile file disappears then reappears and the command gets stuck at the same stage again).

This time, when I stop it, it prints the following message:

$ make
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
make: *** [Makefile:224: cmake_check_build_system] Interrupt

I've tried to look up the Makefile and it seems to be the following command that blocks:

cmake_check_build_system:
    $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-    build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system

I searched and found this thread, so it seems to just be a way to set the directories. I've tried running it manually and the result is the same:

$ cmake -H../Sources -B. --check-build-system CMakeFiles/Makefile.cmake 0
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
[ -- stuck - nothing happens here -- ]

I don't know what I'm doing wrong and I'm stuck, could someone help me?


Edit: running make in verbose mode gives a little more information:

$ make VERBOSE=1
/usr/bin/cmake.exe -H/cygdrive/e/Projects/MyProject/Sources -B/cygdrive/e/Projects/MyProject/Build_Cygwin --check-build-system CMakeFiles/Makefile.cmake 0
Re-run cmake: build system dependency is missing
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
Darkiwi
  • 227
  • 1
  • 4
  • 14
  • 1
    Try to configure a **simple** CMake project. If it will succeed (no 'stuck' after `-- Configuring done` message), then the problem depends on your `CMakeLists.txt`, and for resolve the problem we need to see your `CMakeLists.txt` (in form of [mcve]). – Tsyvarev Nov 29 '18 at 14:29
  • 1
    Maybe the wrong cmake is being used? If you have the windows version and cygwin version both installed maybe the wrong one is invoked. Also try using the `--trace` option. It might report what is happening after the `-- Configuring done` message. – fdk1342 Nov 29 '18 at 15:57

1 Answers1

1

As suggested by Fred, I used --trace to get more info --> there was absolutely nothing after Configuring done.

Then, as suggested by Tsyvarev, I simplified the CMakeLists to the bare minimum, where it was ok. Then I added things bit by bit until I identified the issue.

It came from cmake path variables that contained drive letters (like "E:/...") that made cmake go nuts and get stuck.

I made a small macro to patch all path variable, replacing drive letters by "/cygdrive/[drive letter]/..." and after patching them all, everything went back to normal. For those interested:

macro(PatchPath PATHTOPATCH OUTPUT_VAR)
if(${TARGET_SYSTEM_TYPE} MATCHES "cygwin")
    string(SUBSTRING ${PATHTOPATCH} 0 1 CYG_DRIVE)
    string(TOLOWER ${CYG_DRIVE} CYG_DRIVE)
    string(SUBSTRING ${PATHTOPATCH} 2 -1 TMP_END_OF_PATH)
    set(${OUTPUT_VAR} "/cygdrive/${CYG_DRIVE}${TMP_END_OF_PATH}")
endif()
endmacro()

Thanks everyone!

Darkiwi
  • 227
  • 1
  • 4
  • 14