microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.16k stars 6.39k forks source link

How do I convert qmake to cmake? #18090

Closed Foxxiaohanghang closed 3 years ago

Foxxiaohanghang commented 3 years ago

I downloaded a python script in github. HERE IS THE LINK: while i'm running cmake-gui 3.19.7 to configure the cmakelist.txt in my project, it comes out such two issues.

CMake Error at src/shared/ribbon/CMakeLists.txt:8 (add_library): The target name "$$member" is reserved or not valid for certain CMake features, such as generator expressions, and may result in undefined behavior.

CMake Error at src/shared/ribbon/CMakeLists.txt:9 (target_link_libraries): Cannot specify link libraries for target "$$member" which is not built by this project.

the cmakelist.txt down below: cmake_minimum_required(VERSION 3.0.0 ) project(ribbon) set (CMAKE_PREFIX_PATH "D:\software\Qt131\1\5.13.1\msvc2017_64\") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Gui) find_package(Qt5Core) add_library($$member(TARGET, 0) static ) target_link_libraries($$member(TARGET, 0) static PRIVATE Qt5::Gui Qt5::Core) target_compile_definitions($$member(TARGET, 0) static PRIVATE QTITAN_LIBRARY_STATIC) target_compile_definitions($$member(TARGET, 0) static PRIVATE QTITAN_LIBRARY) set_target_properties($$member(TARGET, 0) static PROPERTIES DEBUG_POSTFIX "d") install(TARGETS $$member(TARGET, 0) static DESTINATION Libs)

VS VERSION: VISUAL STUIDIO 15 2017 X64

QT VERSION:5.13.1

Neumann-A commented 3 years ago

cmake_minimum_required(VERSION 3.0.0 )

bump to at least cmake_minimum_required(VERSION 3.17

$$member(TARGET, 0)

is not valid cmake as the error indicates. Try replacing it with MyApp or MyLib

Also this is not StackOverflow. Please close this issue which is unrelated to vcpkg!

Foxxiaohanghang commented 3 years ago

Thank u so mush!and this is the first time I question on github.I apologize for the wrong way of posting! and I tried the solutions,.However,after I replace '$$member(TARGET,0)' ,it comes with some new errors. do u know how to slove these errors? thanks!

here is the CMakeList.txt

cmake_minimum_required(VERSION 3.19.7 ) project(ribbon) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Core) find_package(Qt5Gui) add_library(MyLib static ) target_link_libraries(MyLib static PRIVATE Qt5::Core Qt5::Gui) target_compile_definitions(MyLib static PRIVATE QTITAN_LIBRARY_STATIC) target_compile_definitions(MyLib static PRIVATE QTITAN_LIBRARY) set_target_properties(MyLib static PROPERTIES DEBUG_POSTFIX "d") install(TARGETS MyLib static DESTINATION Libs)

Here is the error

CMake Error at src/shared/ribbon/CMakeLists.txt:8 (target_link_libraries): The INTERFACE, PUBLIC or PRIVATE option must appear as the second argument, just after the target name.

CMake Error at src/shared/ribbon/CMakeLists.txt:9 (target_compile_definitions):

target_compile_definitions called with invalid arguments

CMake Error at src/shared/ribbon/CMakeLists.txt:10 (target_compile_definitions):

target_compile_definitions called with invalid arguments

CMake Error at src/shared/ribbon/CMakeLists.txt:11 (set_target_properties):

set_target_properties Can not find target to add properties to: static

CMake Error at src/shared/ribbon/CMakeLists.txt:12 (install):

install TARGETS given target "static" which does not exist.