cross-compiling from Linux to get an executable windows
-
Hello,
I am trying to compile from Linux a Windows executable.
I have create the following script:
sudo apt install mingw-w64 -y mkdir build-win && cd build-win cmake \ -DCMAKE_TOOLCHAIN_FILE=../mingw_toolchain.cmake \ -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x.x/mingw_64/lib/cmake make``` My CMakeLists.txt is the following one: ```cmake_minimum_required(VERSION 3.16) project(hello_world LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) add_executable(hello_world main.cpp ) target_link_libraries(hello_world Qt${QT_VERSION_MAJOR}::Core) include(GNUInstallDirs) install(TARGETS hello_world LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
When I execute my script I get the following error:
No source or binary directory provided. Both will be assumed to be the same as the current working directory, but note that this warning will become a fatal error in future CMake releases. CMake Error: The source directory "/home/leyva/QtProjects/hello_world/build-win" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. make: *** No targets specified and no makefile found. Stop.
Thanks in advance.
-
As the error message tells you, you forgot to specify the source directory.