开发者

Adding projects to a visual studio c++ solution via a script

开发者 https://www.devze.com 2023-01-19 13:46 出处:网络
I usually work on multi-project solutions in visual studio. 开发者_开发技巧Since the solutions themselves are not stored in the repository, I spend some time adding in the various projects via visual

I usually work on multi-project solutions in visual studio. 开发者_开发技巧Since the solutions themselves are not stored in the repository, I spend some time adding in the various projects via visual studio(from a list which is part of the 'parent' project). I am wondering if I can acommplish this via a script. ie: 1. create a solution. 2 add projects to that solution.

I have a supplementary I need to add to the above question. I can use the File.AddProject from within the command window of visual studio(assuming you have a project open). I can also use File.OpenExistingProject from outside of visual studio using devenv /command .. Now the only missing piece is how do I add exisitng project to the project(solution) that is open, from outside of visual studio.


You should give a try to CMake. Here is a CMakeLists.txt example that creates a library and two binaries using that library. After using CMake program, you end up with a solution and 3 projects inside.

project(MyProject)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
file(GLOB_RECURSE common_files common/*.h common/*.cpp)
add_library(commonLibrary ${common_files})

file(GLOB_RECURSE projectA_files projA/*.h projA/*.cpp)
add_executable(ProgramA ${projectA_files})
target_link_libraries(ProgramA commonLibrary)

file(GLOB_RECURSE projectB_files projB/*.h projB/*.cpp)
add_executable(ProgramB ${projectB_files})
target_link_libraries(ProgramB commonLibrary)


I have to admit , I did'nt try Cmake , mostly because I thought what I was looking for should be exposed in visual studio itself. I have the elements of the solution. windows command prompt to add an alias for AddExistingProject followed by a command prompt run of devenv /commandline. It should be possible to write a script that utilizes these elements.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号