Generate two Visual Studio Solutions at same folder using CMake

Cobaia

Using CMake, I am trying to this:

Create two Visual Studio solutions at same folder.

eg.:

root
|
|-- myproject.sln
|-- myproject_x64.sln

Generated with command line (.bat file):

cmake -G"Visual Studio 10"
del CMakeCache.txt // POG to generate win64 in the sequence "CMake ZERO_CHECK will cry"
cmake -G"Visual Studio 10 Win64"

Inside cmake file:

PROJECT(myproject)

IF(NOT "${CMAKE_CL_64}" MATCHES "0")
    MESSAGE( STATUS "Generating x64 Solution...")
    PROJECT(myproject_x64)
ELSE()
    MESSAGE( STATUS "Generating x86 Solution...")
ENDIF()

(...)

Is it possible to do something like this ?

The CMake always generate ALL_BUILD project resulting this:

root
|-- source/header files
|-- unittest.vcxproj
|
|-- ALL_BUILD.vcxproj (used for last generated project)
|-- myproject.sln
|-- myproject_x64.sln

Is there a way to create subdirectories for (ALL_BUILD.vcxproj,INSTALL.vcxproj,PACKAGE.vcxproj, ZERO_CHECK.vcxproj) ?

eg.:

root
|-- source/header files
|-- unittest.vcxproj
|
|-- myproject.sln
|-- myproject_x64.sln
|
|---- depDir
        |
        | (used for myproject)
        |-- ALL_BUILD.vcxproj 
        |-- INSTALL.vcxproj
        |-- PACKAGE.vcxproj
        |-- ZERO_CHECK.vcxproj
|---- depDir_x64
        |
        | (used for myproject_x64)
        |-- ALL_BUILD.vcxproj 
        |-- INSTALL.vcxproj
        |-- PACKAGE.vcxproj
        |-- ZERO_CHECK.vcxproj

OR "preferable"

root
|-- source/header files
|-- unittest.vcxproj
|
|-- myproject.sln
|-- myproject_x64.sln
|
|-- ALL_BUILD.vcxproj (used for myproject)
|-- INSTALL.vcxproj (used for myproject)
|-- PACKAGE.vcxproj (used for myproject)
|-- ZERO_CHECK.vcxproj
|
|---- depDir_x64
        |
        | (used for myproject_x64)
        |-- Additional CMakeLists.txt if needed.
        |-- ALL_BUILD.vcxproj 
        |-- INSTALL.vcxproj
        |-- PACKAGE.vcxproj
        |-- ZERO_CHECK.vcxproj

Is it possible to do something like this ?

Cobaia

I found a good alternative!

I create a .bat file to generate x86, x64 folders and use a single CMakeLists file.

@echo off
echo Generating x86 Solution...

mkdir x86
cd x86
cmake -G"Visual Studio 10" "../"
cd ..
mkshortcut "../" /target:"%~dp0\x86\myproject.sln" /shortcut:"myproject.sln"

echo Generating x64 Solution...

mkdir x64
cd x64
cmake -G"Visual Studio 10 Win64" "../"
cd ..
mkshortcut "../" /target:"%~dp0\x64\myproject.sln" /shortcut:"myproject_x64.sln"

pause

Using

cd x86 

and

cmake "../" 

I can generate files inside x86 folder.

The result is:

root
|-- source/header files
|-- x86 <- folder
|-- x64 <- folder
|-- CMakeLists.txt
|-- myproject.sln <-shortcut to x86 .sln
|-- myproject_x64.sln <-shortcut to x64 .sln

The code to create shortcut file

mkshortcut "../" /target:"%~dp0\x86\myproject.sln" /shortcut:"myproject.sln"

Uses mkshortcut.vbs taken from giannistsakiris.com

rem This code is used to generate files shortcuts
rem eg.:
rem mkshortcut /target:"c:\myfile" /shortcut:"c:\myfileShortcut"

set WshShell = WScript.CreateObject("WScript.Shell" )
set oShellLink = WshShell.CreateShortcut(Wscript.Arguments.Named("shortcut") & ".lnk")
oShellLink.TargetPath = Wscript.Arguments.Named("target")
oShellLink.WindowStyle = 1
oShellLink.Save

To see if cmake -G"Visual Studio 10 Win64" was used:

IF(NOT "${CMAKE_CL_64}" MATCHES "0")
...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Can I open two solutions with Visual Studio for Mac at the same time?

How to generate 64 bit Visual Studio project for LLVM using CMake?

Why is Visual Studio creating two DLLs with the same name in the bin folder?

What is the .vs folder used for in Visual Studio solutions?

Folder structure for a Visual Studio 2017 with CMake

Generate visual studio solution on mac with cmake

Creating C# and C++/CLR projects in the same solution using CMake (CMake targeting visual studio)

How to generate a Visual Studio project that uses the Intel Compiler using cmake under Windows

How to generate the Zip using powershell with in same folder

Visual Studio recompiles projects that are shared between two solutions for no reason

Unresolved Externals using Cmake and Visual Studio 2013

How to open a different tab in same folder using sublime text or visual studio code?

How to generate ipa using visual studio for ios

Is programming in Visual Basic using Visual studio same as Visual studio enterprise?

cmake keeps regenerating cache [cmake + visual studio open folder + ninja + clang-cl]

Generate two different package using CPack in cmake : Linux

What would be a good .gitignore file for the ROOT folder of all Visual Studio solutions?

Visual Studio Project rearrange project into folder with same name

Use a python package in the same project folder in visual studio code

CUDA with visual studio and cmake

Using constant folder with cmake

Compare two strings using Visual Studio Code?

Using Cmake to build ssh.dll with Visual Studio 2017

How to set Visual Studio Filters for nested sub directory using cmake

Building TBB using Visual Studio 2015 x64 and CMake

Visual Studio 2017 - How to create a project from the source using CMake?

How to run Cmake in Visual Studio Code using tasks

Detect build type (debug/release) in visual studio when using CMake

How to make relative file path work in visual studio using cmake?