使用CMake,我正在努力:
在同一文件夹中创建两个Visual Studio解决方案。
例如:
root
|
|-- myproject.sln
|-- myproject_x64.sln
使用命令行生成(.bat文件):
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"
在cmake文件中:
PROJECT(myproject)
IF(NOT "${CMAKE_CL_64}" MATCHES "0")
MESSAGE( STATUS "Generating x64 Solution...")
PROJECT(myproject_x64)
ELSE()
MESSAGE( STATUS "Generating x86 Solution...")
ENDIF()
(...)
是否可以做这样的事情?
CMake始终生成ALL_BUILD项目,结果如下:
root
|-- source/header files
|-- unittest.vcxproj
|
|-- ALL_BUILD.vcxproj (used for last generated project)
|-- myproject.sln
|-- myproject_x64.sln
有没有办法为(ALL_BUILD.vcxproj,INSTALL.vcxproj,PACKAGE.vcxproj,ZERO_CHECK.vcxproj)创建子目录?
例如:
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
或“优先”
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
是否可以做这样的事情?
答案 0 :(得分:0)
我找到了一个很好的选择!
我创建一个.bat文件来生成x86,x64文件夹并使用一个CMakeLists文件。
@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
使用
cd x86
和
cmake "../"
我可以在x86文件夹中生成文件。
结果是:
root
|-- source/header files
|-- x86 <- folder
|-- x64 <- folder
|-- CMakeLists.txt
|-- myproject.sln <-shortcut to x86 .sln
|-- myproject_x64.sln <-shortcut to x64 .sln
创建快捷方式文件的代码
mkshortcut "../" /target:"%~dp0\x86\myproject.sln" /shortcut:"myproject.sln"
的mkshortcut.vbs
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
查看是否使用了cmake -G“Visual Studio 10 Win64”:
IF(NOT "${CMAKE_CL_64}" MATCHES "0")
...