kobi89
kobi89

Reputation: 162

How to transform from CMake to a plain Visual Studio project?

I am able to CMake build this HelloWorld example project using cmakelists.txt file and generate a visual studio project.

project(helloworld LANGUAGES C CXX)
cmake_minimum_required(VERSION 3.5)

find_package(Idlpp-cxx REQUIRED)
if (NOT TARGET CycloneDDS-CXX::ddscxx)
  find_package(CycloneDDS-CXX REQUIRED)
endif()

# Convenience function, provided by the Idlpp-cxx that generates a CMake
# target for the given IDL file. The function calls Idlcpp-cxx to generate
# source files and compiles them into a library.
idl_ddscxx_generate(ddscxxHelloWorldData_lib "HelloWorldData.idl")

add_executable(ddscxxHelloworldPublisher publisher.cpp)
add_executable(ddscxxHelloworldSubscriber subscriber.cpp)

# Link both executables to idl data type library and ddscxx.
target_link_libraries(ddscxxHelloworldPublisher ddscxxHelloWorldData_lib     CycloneDDS-CXX::ddscxx)
target_link_libraries(ddscxxHelloworldSubscriber ddscxxHelloWorldData_lib CycloneDDS-CXX::ddscxx)

set_property(TARGET ddscxxHelloworldPublisher PROPERTY CXX_STANDARD 11)
set_property(TARGET ddscxxHelloworldSubscriber PROPERTY CXX_STANDARD 11)

I need to create the same project without cmakelists.txt and CMake

How to do this only using visual studio? where to define those commands in CMakelists.txt in visual studio if I create an empty c++ project

I have tried this making an empty project.

I don't know how to idl_ddscxx_generate and target_link_libraries perform in VS....

idl_ddscxx_generate has to run if IDL file has changed target_link_libraries is required if I added new source files to the project....

Upvotes: 0

Views: 552

Answers (1)

usr1234567
usr1234567

Reputation: 23294

  1. Make a new, empty Visual Studio project.
  2. Copy all source files except the CMake files.
  3. Do whatever you do in a Visual Studio project. Add files, targets, dependecies, … If you are not sure, look up what is written in the CMakeLists.txt file.
  4. Delete all CMake files in your original project and copy your Visual Studio project files.
  5. Add these changes (deleted CMake files, added VS project files) to your Subversion repository, maybe do this in a branch that others can test it, report back, and improve the change. Once done, merge the branch.

Probably, add step 0.: Learn how Visual Studio organizes its project. Make a tutorial, take some training.

Remark: Whatever your problem is with CMake, you missed something. But you can find this out later and revert your changes and pick up CMake up again.

Upvotes: 1

Related Questions