Bug fixes in cmakeBuild.cmd. --config Debug works correctly. Documentation update. Remove 'u' postfix ABI incompatibility.

This commit is contained in:
Robin Mills 2017-09-08 22:44:54 +01:00
parent 60d436c969
commit b9ccc70bcc
6 changed files with 144 additions and 102 deletions

View File

@ -55,12 +55,7 @@ if( EXIV2_ENABLE_COMMERCIAL )
endif()
if( MSVC )
if ( EXIV2_ENABLE_WIN_UNICODE )
set(CMAKE_DEBUG_POSTFIX "du")
set(CMAKE_RELEASE_POSTFIX "u")
else()
set(CMAKE_DEBUG_POSTFIX "d")
endif()
set(CMAKE_DEBUG_POSTFIX "d")
endif()
if( EXIV2_ENABLE_XMP )

View File

@ -32,16 +32,16 @@ How to use this
out of this - provided Visual Studio is installed in %ProgramFiles(x86)%
%ProgramFiles(x86)% is usually c:\Program Files (x86)
vcvars 2005 # sets 2005 x86
vcvars 2010 64 # sets 2010 x86_amd64
vcvars 2005 32 # sets 2005 x86
vcvars 2010 64 # sets 2010 amd64
2 Always build "out of source". I recommend:
cd <exiv2dir>\contrib\cmake\cmake
cmd.exe
vcvars 2015 64
cmakeBuild --help # display syntax and options
cmakeBuild --rebuild
....
vcvars 2015 64
cmakeBuild --help # display syntax and options
cmakeBuild --build
....
exit
+-------------------------------------------------------+
@ -67,26 +67,28 @@ How to use this
3 Options
C:\Users\rmills\gnu\github\clanmills\exiv2\contrib\cmake\msvc>cmakeBuild --help
Options: --help | --webready | --rebuild | --video | --static | --unicode | --nls
--silent | --verbose | --pause | --dryrun | --test | --trace
Options: --help | --silent | --verbose | --pause | --dryrun | --trace | --test
--build | --static | --unicode | --nls | --webready | --video | --samples
--exiv2 C:\Users\rmills\gnu\github\clanmills\exiv2 | --work work | --config Release | --generator generator
--zlib zlib-1.2.8 | --expat expat-2.1.0 | --curl curl-7.45.0 | --libssh libssh-0.7.2
--bash c:\cygwin64\bin\bash.exe
Option switches.
--help Print help message and quit
--webready Build and Link the webready feature
--rebuild Delete "relics" from a previous build such as CMakeBuild.txt
--video Build and link video support
--static Build and link static libraries and programs
--nosamples Do not build sample applications
--unicode Build UNICODE path support
--nls Build with Natural Language Support
--silent Run script with minimal "chatter"
--verbose Run script with maximum "chatter"
--trace Show commands begin executed by the script
--pause Pause at every build step
--dryrun Don't build anything. Report and quit
--trace Show commands begin executed by the script (implies --build --samples)
--test Execute the test suite after the build
--build Build the code
--static Build and link static libraries and programs
--unicode Build UNICODE path support
--nls Build with Natural Language Support
--webready Build and Link the webready feature
--video Build and link video support
--samples Include samples in projects
Option/values (See section 9 below)
--zlib zlib-1.2.8
@ -95,13 +97,13 @@ How to use this
--libssh libssh-0.7.2
Other build key/value pairs:
--config Release | Debug
--config Release | Debug (shorthand = --release --debug)
--generator The script default is almost always correct and is passed as -G "Generator" to CMake
--work The "work" directory in which the build will be performed (see 4 below)
--bash Path to bash.exe to be used when --test is specified.
4 What gets built?
The build is performed in work
The build is performed in work_Config
The output is generated in dist
dist\..mumble..\bin contains *.exe and *.dll files
dist\..mumble..\lib contains *.lib files
@ -109,10 +111,10 @@ How to use this
mumble identifies the compiler and build.
Example C:\gnu\github\exiv2\contrib\cmake\msvc\dist\2013\x64\dll\Release\bin
2013 = Visual Studio Choices: 2005/2008/2010/2012/2013/2015
x64 = 64 bit build Win32/x64
dll = shared library dll/static
Release = configuration Release/Debug/RelWithDebInfo/MinSizeRel
2013 = Visual Studio Choices: 2005 | 2008 | 2010 | 2012 | 2013 | 2015 | 2017
x64 = 64 bit build Win32 | x64
dll = shared library dll | static
Release = configuration Release | Debug | RelWithDebInfo | MinSizeRel
5 Building manually with CMake
The cmake option -G Generator should be chosen for the version of Visual Studio installed.
@ -250,4 +252,4 @@ How to use this
Robin Mills
robin@clanmills.com
Updated: 2017-09-05
Updated: 2017-09-08

View File

@ -2,7 +2,7 @@
int main(int,const char**)
{
const char* vs[] = { "unknown" , "2005", "2008", "2010", "2012", "2013", "2015" };
const char* vs[] = { "unknown" , "2005", "2008", "2010", "2012", "2013", "2015","2017" };
int v = (_MSC_VER-1300)/100;
if ( v < 0 || v >= (sizeof(vs)/sizeof(vs[0])) ) v = 0;
fprintf(stderr,"_%s = %d (%s) sizeof(void*) = %d\n","MSC_VER",_MSC_VER,vs[v],(int)sizeof(void*));

View File

@ -1,43 +1,68 @@
@echo off
setlocal enableextensions
rem ----
rem always run this script in <exiv2dir>/contrib/cmake/msvc
cd %~dp0
set "_BUILDDIR_=%CD%"
call:echo calling cmakeDefaults.cmd
call cmakeDefaults.cmd
IF ERRORLEVEL 1 (
echo "*** cmakeDefaults.cmd has failed ***" >&2
GOTO error_end
)
:GETOPTS
if /I "%1" == "--bash" set "_BASH_=%2"& shift
if /I "%1" == "--config" set "_CONFIG_=%2"& shift
if /I "%1" == "--curl" set "_CURL_=%2"& shift
if /I "%1" == "--exiv2" set "_EXIV2_=%2"& shift
if /I "%1" == "--expat" set "_EXPAT_=%2"& shift
if /I "%1" == "--generator" set "_GENERATOR_=%2"& shift
if /I "%1" == "--openssl" set "_OPENSSL_=%2"& shift
if /I "%1" == "--libssh" set "_LIBSSH_=%2"& shift
if /I "%1" == "--work" set "_WORK_=%2"& shift
if /I "%1" == "--zlib" set "_ZLIB_=%2"& shift
set _CLAIMED_=0
if /I "%1" == "--bash" call:set "_BASH_=%2"& shift
if /I "%1" == "--config" call:set "_CONFIG_=%2"& shift
if /I "%1" == "--curl" call:set "_CURL_=%2"& shift
if /I "%1" == "--exiv2" call:set "_EXIV2_=%2"& shift
if /I "%1" == "--expat" call:set "_EXPAT_=%2"& shift
if /I "%1" == "--generator" call:set "_GENERATOR_=%2"& shift
if /I "%1" == "--openssl" call:set "_OPENSSL_=%2"& shift
if /I "%1" == "--libssh" call:set "_LIBSSH_=%2"& shift
if /I "%1" == "--work" call:set "_WORK_=%2"& shift
if /I "%1" == "--zlib" call:set "_ZLIB_=%2"& shift
if /I "%1" == "--help" call:Help && goto end
if /I "%1" == "--dryrun" set "_DRYRUN_=1"
if /I "%1" == "--samples" set "_SAMPLES_=1"
if /I "%1" == "--pause" set "_PAUSE_=1"
if /I "%1" == "--rebuild" set "_REBUILD_=1"
if /I "%1" == "--silent" set "_SILENT_=1"
if /I "%1" == "--static" set "_MODE_=static"
if /I "%1" == "--test" (set "_TEST_=1" & set _SAMPLES_=1)
if /I "%1" == "--trace" set ("_VERBOSE_=1 && echo on)"
if /I "%1" == "--verbose" set "_VERBOSE_=1"
if /I "%1" == "--video" set "_VIDEO_=1"
if /I "%1" == "--webready" set "_WEBREADY_=1"
if /I "%1" == "--unicode" set "_UNICODE_=ON"
if /I "%1" == "--nls" set "_NLS_=ON"
if /I "%1" == "--dryrun" call:set "_DRYRUN_=1"
if /I "%1" == "--build" call:set "_BUILD_=1"
if /I "%1" == "--samples" call:set "_SAMPLES_=1"
if /I "%1" == "--pause" call:set "_PAUSE_=1"
if /I "%1" == "--silent" call:set "_SILENT_=1"
if /I "%1" == "--static" call:set "_SHARED_=0"
if /I "%1" == "--shared" call:set "_SHARED_=1"
if /I "%1" == "--dll" call:set "_SHARED_=1"
if /I "%1" == "--test" call:set "_TEST_=1"
if /I "%1" == "--trace" call:set "_TRACE_=1"
if /I "%1" == "--verbose" call:set "_VERBOSE_=1"
if /I "%1" == "--video" call:set "_VIDEO_=1"
if /I "%1" == "--webready" call:set "_WEBREADY_=1"
if /I "%1" == "--unicode" call:set "_UNICODE_=1"
if /I "%1" == "--ascii" call:set "_UNICODE_=0"
if /I "%1" == "--nls" call:set "_NLS_=1"
if /I "%1" == "--debug" call:set "_CONFIG_=Debug"
if /I "%1" == "--release" call:set "_CONFIG_=Release"
if /I "%_CLAIMED_%" == "0" (
echo "*** unknown command argument %1 ***" >&2
goto error_end
)
shift
if not (%1) EQU () goto GETOPTS
goto main
:set
set %1
set _CLAIMED_=1
exit /b 0
:help
call cmakeDefaults >NUL 2>NUL
echo Options: --help ^| --webready ^| --rebuild ^| --video ^| --static ^| --unicode ^| --nls
echo. --silent ^| --verbose ^| --pause ^| --dryrun ^| --test ^| --samples ^| --trace
echo Options: --help ^| --silent ^| --verbose ^| --pause ^| --dryrun ^| --trace ^| --test
echo. --build ^| --static ^| --unicode ^| --nls ^| --webready ^| --video ^| --samples
echo. --exiv2 %_EXIV2_% ^| --work %_WORK_% ^| --config %_CONFIG_% ^| --generator generator
echo. --zlib %_ZLIB_% ^| --expat %_EXPAT_% ^| --curl %_CURL_% ^| --libssh %_LIBSSH_%
echo. --bash %_BASH_%
@ -48,40 +73,40 @@ echo.&&echo.&&echo.
echo.------ cmakeBuild Settings ----------
echo.bash = %_BASH_%
echo.binpath = %_BINPATH_%
echo.build = %_BUILD_%
echo.builddir = %_BUILDDIR_%
echo.config = %_CONFIG_%
echo.curl = %_CURL_%
echo.dryrun = %_DRYRUN_%
echo.exiv2 = %_EXIV2_%
echo.expat = %_EXPAT_%
echo.generator = %_GENERATOR_%
echo.install = %_INSTALL_%
echo.incpath = %_INCPATH_%
echo.libpath = %_LIBPATH_%
echo.libssh = %_LIBSSH_%
echo.mode = %_MODE_%
echo.nls = %_NLS_%
echo.openssl = %_OPENSSL_%
echo.unicode = %_UNICODE_%
echo.work = %_WORK_%
echo.platform = %PLATFORM%
echo.samples = %_SAMPLES_%
echo.shared = %_SHARED_%
echo.test = %_TEST_%
echo.video = %_VIDEO_%
echo.unicode = %_UNICODE_%
echo.vc = %_VC_%
echo.video = %_VIDEO_%
echo.vs = %_VS_%
echo.webready = %_WEBREADY_%
echo.work = %_WORK_%
echo.zlib = %_ZLIB_%
echo.&&echo.&&echo.
exit /b 0
:main
call:report
if NOT DEFINED _SILENT_ set _VERBOSE_=1
set _UNSUPPORTED_=
rem ----
call:echo calling cmakeDefaults.cmd
call cmakeDefaults
IF ERRORLEVEL 1 (
echo "*** cmakeDefaults.cmd has failed ***" >&2
GOTO error_end
)
call:echo _EXIV2_ = %_EXIV2_%
rem ----
@ -110,11 +135,17 @@ if NOT DEFINED _VS_ (
)
call:echo testing architecture
if "%PROCESSOR_ARCHITECTURE%" EQU "x86" (
set _ARCH_=64
if /I "%PROCESSOR_ARCHITECTURE%" == "x86" set _ARCH_=32
if /I "%VSCMD_ARG_HOST_ARCH%" == "x86" set _ARCH_=32
if /I "%_ARCH_%" == "32" (
set Platform=Win32
set RawPlatform=x86
set CpuPlatform=ia32
) ELSE (
)
if NOT DEFINED Platform (
set Platform=x64
set RawPlatform=x64
set CpuPlatform=intel64
@ -169,23 +200,36 @@ IF ERRORLEVEL 1 (
GOTO error_end
)
rem ----
call:echo fix ups
set _WORK_=%_WORK_%_%_CONFIG_%
if DEFINED _TRACE_ (
set _VERBOSE_=1
echo on
)
if DEFINED _TEST_ (
set _SAMPLES_=1
set _BUILD_=1
)
if /I "%_SHARED_%" == "1" set _MODE_=dll
if /I "%_SHARED_%" == "0" set _MODE_=static
rem ----
call:echo testing work directory _WORK_ = %_WORK_%
if defined _REBUILD_ if EXIST "%_WORK_%" rmdir/s/q "%_WORK_%"
if defined _REBUILD_ del/s CMakeCache.txt >NUL 2>NUL
if EXIST "%_WORK_%" rmdir/s/q "%_WORK_%"
del/s CMakeCache.txt >NUL 2>NUL
IF NOT EXIST "%_WORK_%" mkdir "%_WORK_%"
pushd "%_WORK_%"
set "_WORK_=%CD%"
set "_WORK_=%CD%"
popd
call:echo _WORK_ = %_WORK_%
call:echo _WORK_ = %_WORK_%
rem ----
call:echo testing INSTALL
SET _INSTALL_=dist\%_VS_%\%Platform%\%_MODE_%\%_CONFIG_%
if NOT EXIST %_INSTALL_% mkdir %_INSTALL_%
IF NOT EXIST %_INSTALL_% mkdir %_INSTALL_%
pushd %_INSTALL_%
set "_INSTALL_=%CD%"
set "_INSTALL_=%CD%"
popd
call:echo _INSTALL_ = %_INSTALL_%
@ -204,8 +248,7 @@ if defined _TEST_ if NOT EXIST "%_BASH_%" (
if NOT DEFINED _GENERATOR_ set "_GENERATOR_=%VS_CMAKE%"
if /I "%_GENERATOR_%" == "NMake" set "_GENERATOR_=NMake Makefiles"
if /I "%_MODE_%" == "static" "_LINK_=-DCMAKE_LINK=static"
if /I "%_SHARED_%" == "0" set _LINK_="-DCMAKE_LINK=static"
call:cltest
call:report
@ -218,10 +261,10 @@ call:buildLib %_ZLIB_% -DCMAKE_INSTALL_PREFIX=%_INSTALL_%
echo ---------- EXPAT building with cmake -----------------
set "_TARGET_=--target expat"
if /I "%_MODE_%" == "static" (
call:buildLib %_EXPAT_% -DCMAKE_INSTALL_PREFIX=%_INSTALL_% -DBUILD_shared=0 -DCMAKE_C_FLAGS_RELEASE=/MT -DBUILD_examples=0 -DBUILD_tests=0
if /I "%_SHARED_%" == "0" (
call:buildLib %_EXPAT_% -DCMAKE_INSTALL_PREFIX=%_INSTALL_% -DBUILD_shared=0 -DCMAKE_C_FLAGS_RELEASE=/MT -DCMAKE_C_FLAGS_DEBUG=/MTd -DBUILD_examples=0 -DBUILD_tests=0
) else (
call:buildLib %_EXPAT_% -DCMAKE_INSTALL_PREFIX=%_INSTALL_%
call:buildLib %_EXPAT_% -DCMAKE_INSTALL_PREFIX=%_INSTALL_% -DBUILD_examples=0 -DBUILD_tests=0
)
set _TARGET_=
@ -244,7 +287,7 @@ if DEFINED _WEBREADY_ (
call:buildLib %_CURL_% -DCMAKE_INSTALL_PREFIX=%_INSTALL_% -DCMAKE_LIBRARY_PATH=%_LIBPATH_% -DCMAKE_INCLUDE_PATH=%_INCPATH_% -DWITH_GSSAPI=OFF -DWITH_ZLIB=OFF -DWITH_SFTP=OFF -DWITH_SERVER=OFF -DWITH_EXAMPLES=OFF -DWITH_NACL=OFF -DWITH_PCAP=OFF -DCMAKE_USE_LIBSSH2=OFF -DCMAKE_USE_LIBSSH=OFF
if errorlevel 1 set _WEBREADY_=
) ELSE (
if defined _REBUILD_ rmdir/s/q "%_ONCPATH_%\curl" >NUL 2>NUL
rmdir/s/q "%_ONCPATH_%\curl" >NUL 2>NUL
if NOT EXIST "%_ONCPATH_%"\curl (
echo ---------- CURL building with nmake -----------------
IF NOT EXIST %_CURL_%.tar.gz svn export svn://dev.exiv2.org/svn/team/libraries/%_CURL_%.tar.gz >NUL
@ -273,8 +316,8 @@ if NOT DEFINED _WEBREADY_ set _CURL_= && set _LIBSSH_=
echo ---------- EXIV2 building with cmake ------------------
set "EXIV_B=%_WORK_%\exiv2"
if defined _REBUILD_ IF EXIST "%EXIV_B%" rmdir/s/q "%EXIV_B%"
IF NOT EXIST "%EXIV_B%" mkdir "%EXIV_B%"
IF EXIST "%EXIV_B%" rmdir/s/q "%EXIV_B%"
IF NOT EXIST "%EXIV_B%" mkdir "%EXIV_B%"
pushd "%EXIV_B%"
set ENABLE_CURL=-DEXIV2_ENABLE_CURL=OFF
@ -308,14 +351,16 @@ pushd "%EXIV_B%"
goto error_end
)
call:run cmake --build . --config %_CONFIG_%
rem if DEFINED _BUILDX_ devenv %_WORK_%\exiv2\exiv2.sln /Build "%_CONFIG_%|%Platform%" /ProjectConfig INSTALL
if DEFINED _BUILD_ call:run cmake --build . --config %_CONFIG_%
IF errorlevel 1 (
echo "*** build errors in EXIV2 ***" >&2
popd
goto error_end
)
call:run cmake --build . --config %_CONFIG_% --target install
if DEFINED _BUILD_ call:run cmake --build . --config %_CONFIG_% --target install
IF errorlevel 1 (
echo "*** install errors in EXIV2 ***" >&2
popd
@ -349,7 +394,7 @@ rem echo (or don't if --silent). syntax: call:echo args ...
if NOT DEFINED _SILENT_ echo %*%
exit /b 0
rem run a command. syntax call:run args
rem run a command. syntax call:run args
:run
if defined _VERBOSE_ (
echo.
@ -397,14 +442,14 @@ pushd "%LOB_B%"
rem --static expat fails to install on VS 2010+
set buildLibInstallExpatStatic=0
if /I "%_TARGET_%" == "--target expat" if /I "%_MODE_%" == "static" set buildLibInstallExpatStatic=1
if /I "%buildLibInstallExpatStatic%" == "1" (
rem msvc\expat-2.1.0\lib\expat*.h => msvc\dist\2005\x64\static\Release\include
call:run copy/y "%_BUILDDIR_%\%LOB%\lib\expat*.h" "%_ONCPATH_%"
rem msvc\work\expat-2.1.0\release\*.lib => msvc\dist\2005\x64\static\Release\lib
call:run copy/y "%_WORK_%\%LOB%\%_CONFIG_%\*.lib" "%_INSTALL_%\lib"
) else (
) else (
call:run cmake --build . --config %_CONFIG_% --target install
)
@ -452,7 +497,7 @@ exit /b 0
rem -----------------------------------------
rem this runs the compiler and reports _MSC_VER and sizeof(void*)
:cltest
:cltest
pushd "%_EXIV2_%\contrib\cmake\msvc"
nmake -a cltest.exe
cltest.exe

View File

@ -1 +1 @@
for %%a in (32) do for %%v in (2010 2008 2005) do cmd /c "vcvars %%v %%a && cmakeBuild %* 2>&1"
for %%a in (64 32) do for %%v in (2017 2015 2005) do cmd /c "vcvars %%v %%a && cmakeBuild --build %* 2>&1"

View File

@ -3,19 +3,19 @@
rem set up some defaults to be used by cmakeBuild.cmd and related scripts
rem use environment strings to set defaults which will not be clobbered by this script
if not defined _CONFIG_ SET _CONFIG_=Release
if NOT DEFINED _WORK_ SET _WORK_=work
if NOT DEFINED _EXIV2_ SET _EXIV2_=..\..\..
if NOT DEFINED _CURL_ SET _CURL_=curl-7.45.0
if NOT DEFINED _LIBSSH_ SET _LIBSSH_=libssh-0.7.2
if NOT DEFINED _OPENSSL_ SET _OPENSSL_=openssl-1.0.1p
if NOT DEFINED _ZLIB_ SET _ZLIB_=zlib-1.2.8
if NOT DEFINED _EXPAT_ SET _EXPAT_=expat-2.1.0
if NOT DEFINED _BASH_ SET _BASH_=c:\cygwin64\bin\bash.exe
if NOT DEFINED _MODE_ SET _MODE_=dll
if NOT DEFINED _UNICODE_ SET _UNICODE_=OFF
if NOT DEFINED _NLS_ SET _NLS_=OFF
if NOT DEFINED COPYCMD SET COPYCMD=/Y
if NOT DEFINED _CONFIG_ set _CONFIG_=Release
if NOT DEFINED _WORK_ set _WORK_=work
if NOT DEFINED _EXIV2_ set _EXIV2_=..\..\..
if NOT DEFINED _CURL_ set _CURL_=curl-7.45.0
if NOT DEFINED _LIBSSH_ set _LIBSSH_=libssh-0.7.2
if NOT DEFINED _OPENSSL_ set _OPENSSL_=openssl-1.0.1p
if NOT DEFINED _ZLIB_ set _ZLIB_=zlib-1.2.8
if NOT DEFINED _EXPAT_ set _EXPAT_=expat-2.1.0
if NOT DEFINED _BASH_ set _BASH_=c:\cygwin64\bin\bash.exe
if NOT DEFINED _SHARED_ set _SHARED_=1
if NOT DEFINED _UNICODE_ set _UNICODE_=0
if NOT DEFINED _NLS_ set _NLS_=0
if NOT DEFINED COPYCMD set COPYCMD=/Y
rem ---------- check that EXIV2 exists
echo checking that %_EXIV2_% exists