cmake work in progress - see README-CMAKE and TODO-CMAKE for details

This commit is contained in:
Robin Mills 2012-06-10 04:18:50 +00:00
parent 7b49e908dc
commit 6f769602ae
4 changed files with 102 additions and 71 deletions

View File

@ -49,21 +49,33 @@ if( MSVC )
msvc_runtime_report()
msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
msvc_runtime_report()
set(E expat-2.1.0)
set(Z zlib-1.2.7)
if( NOT IS_DIRECTORY ./../${E} )
set(OUT_OF_SOURCE 1)
endif()
if ( NOT EXPAT_LIBRARY )
# link dependant libraries
# apologies for the duplication of information
# I've been unable to simply this using the 'set' command
set(EXPAT_LIBRARY "../../expat-2.1.0/$(ConfigurationName)/expat")
set(ZLIB_LIBRARY "../../zlib-1.2.7/$(ConfigurationName)/zlib" )
include_directories( ../zlib-1.2.7 ../expat-2.1.0/lib)
set(EXPAT_INCLUDE_DIR ../expat-2.1.0/lib )
set(ZLIB_INCLUDE_DIR ../zlib-1.2.7 )
if (OUT_OF_SOURCE)
set(EXPAT_LIBRARY ../../../${E}/$(ConfigurationName)/expat)
set(ZLIB_LIBRARY ../../../${Z}/$(ConfigurationName)/zlib )
set(EXPAT_INCLUDE_DIR ../${E}/lib )
set(ZLIB_INCLUDE_DIR ../${Z} )
else()
set(EXPAT_LIBRARY ../../${E}/$(ConfigurationName)/expat)
set(ZLIB_LIBRARY ../../${Z}/$(ConfigurationName)/zlib)
set(EXPAT_INCLUDE_DIR ../${E}/lib )
set(ZLIB_INCLUDE_DIR ../${Z} )
endif()
include_directories( ${EXPAT_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ../msvc64/include ../../msvc64/include $(SolutionDir)\\src\\include)
endif()
if ( EXIV2_ENABLE_SHARED )
add_library(expat-2.1.0 SHARED IMPORTED)
add_library(zlib-1.2.7 SHARED IMPORTED)
add_library(${E} SHARED IMPORTED)
add_library(${Z} SHARED IMPORTED)
endif()
##
@ -86,7 +98,6 @@ if( MSVC )
set(CMAKE_CURRENT_BINARY_DIR ${B_DIR})
set(EXECUTABLE_OUTPUT_PATH ${B_DIR})
set(LIBRARY_OUTPUT_PATH ${B_DIR})
endif( MSVC )
IF( EXIV2_ENABLE_XMP )

View File

@ -20,8 +20,7 @@ robin@clanmills.com
-------------------------------------------------------------------------------
Exiv2 uses cmake, a cross-platform build system, to control the
compilation process using platform/compiler independent
configuration files.
compilation process using platform/compiler independent configuration files.
TABLE OF CONTENTS
-----------------
@ -125,14 +124,9 @@ Code FileSystem Layout
I set up my environment as follows:
Directory of C:\gnu.cmake
2012-05-31 09:49 <DIR> exiv2 Vanilla
2012-05-31 09:45 <DIR> expat-2.1.0 source
2012-05-30 16:22 <DIR> zlib-1.2.7 trees
Other versions of expat and zlib make be used (although I've never tested them)
2012-05-19 21:29 <DIR> expat-2.0.1
2012-05-19 21:29 <DIR> zlib-1.2.3
2012-05-19 21:29 <DIR> zlib-1.2.5
2012-05-31 09:49 <DIR> exiv2 | Vanilla
2012-05-31 09:45 <DIR> expat-2.1.0 | source
2012-05-30 16:22 <DIR> zlib-1.2.7 | trees
The command to run cmake is of the form:
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
@ -149,56 +143,60 @@ You can skip step 1 if you have prebuilt libraries (see note below)
1) Building the support libraries expat and zlib with cmake
cd expat-2.1.0
Edit CMakeLists.txt to specify shared or static library
If you wish to use STATIC libries, you'll need the following patch (around line 23)
See "Note about expat-2.1.0/CMakeLists.txt"
If you wish to use a static library (shared is default)
a) set expat-2.1.0/CMakeLists.txt static
option(BUILD_shared "build a shared expat library" ON) <------- Set OFF
b) You'll need the following patch (around line 23)
See "Note about expat-2.1.0/CMakeLists.txt"
--- extract from CMakeLists.txt ---
option(XML_NS "Define to make XML Namespaces functionality available" ON)
--- extract from CMakeLists.txt ---
option(XML_NS "Define to make XML Namespaces functionality available" ON)
# rmills patch begin
include(../exiv2/CMake_msvc.txt)
msvc_runtime_configure(${BUILD_shared})
# rmills patch end
# rmills patch begin
include(../exiv2/CMake_msvc.txt)
msvc_runtime_configure(${BUILD_shared})
# rmills patch end
if(XML_DTD)
--- extract end ---
if(XML_DTD)
--- extract end ---
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
.... rattle roll ....
Open expat.sln and build all.
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
.... rattle roll ....
Open expat.sln and build all.
Similar process for zlib-1.2.7
You will not need to edit CMakeLists.txt (zlib builds shared and dynamic libraries)
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
.... rattle roll ....
Open zlib.sln and build all.
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
.... rattle roll ....
Open zlib.sln and build all.
2) Building exiv2
cd exiv2
Edit CMakeLists.txt to specify shared or static library (and other options)
You may need to change the path specifications to expat and zlib to match your setup
You will find path references in the files:
CMakeLists.txt ./src/CMakeLists.txt and ./samples/CMakeLists.txt
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
.... rattle roll ....
Open exiv2.sln and build all.
CMake recommend building "out of source" which means building in a clean
directory BELOW the source tree:
eg cd exiv2
Edit CMakeLists.txt to specify shared or static library (and other options)
You may need to change the path to expat and zlib to match your setup
mkdir build
cd build
cmake -G "Visual Studio 9 2008 Win64" ..
... rattle roll ...
Open build/exiv2.sln and build all.
3) Location of built files (exiv2.exe, exiv2.dll etc)
exiv2\bin\{ x64 | Win32 }\{ Dynamic|Static }\{Config}\exiv2.exe etc....
exiv2\build\bin\{ x64 | Win32 }\{ Dynamic|Static }\{Config}\exiv2.exe etc....
Config: Debug | MinSizeRel | Release | RelWithDebInfo
The test suite is a bash script and requires Cygwin.
cd /c/gnu/exiv2/test
./testMSVC.sh ${PWD}/../bin/x64/Dynamic/Release
./testMSVC.sh ${PWD}/../build/bin/x64/Dynamic/Release
or
./testMSVC.sh ${PWD}/../bin/x64/Dynamic/ | tee foo.txt
./testMSVC.sh ${PWD}/../build/bin/x64/Dynamic/ | tee foo.txt
./verifyMSVC foo.txt
Note about expat-2.1.0/CMakeLists.txt
-------------------------------------
expat-2.1.0/CMakeLists.txt can build static or dynamic libraries.
@ -214,7 +212,7 @@ However you may wish to use prebuilt versions of zlib, iconv and expat.
Specify the location of the prebuilt libraries on the cmake command line:
For example:
cmake -G "NMake Makefiles" . -DEXPAT_LIBRARY=%KDE4_INSTALL_DIR%/lib/libexpat.lib
cmake -G "NMake Makefiles" .. -DEXPAT_LIBRARY=%KDE4_INSTALL_DIR%/lib/libexpat.lib
ToDo: More information about parameters -DEXPAT_LIBRARTY -DZLIB_LIBRARY etc.

View File

@ -1,6 +1,7 @@
Current Status
ToDo: * Support for out of source builds
ToDo: * Find and link iconv library on Windows
* Polish/improve out of source builds
* Test Cygwin, MinGW, Xcode, NMake and more versions of MSVC
* Revisit searching for zlib, expat and iconv
* Work on the "inherited from Gilles" list below
@ -8,7 +9,8 @@ ToDo: * Support for out of source builds
Bugs: * 2005/32/debug won't run. "SideBySide" error (manifest trouble)
* 2003/32 does not compile (1000's of template errors)
Done: * Add header files to MSVC UI for exiv2lib (and changed exiv2bin->exiv2 and exiv2->exiv2lib)
Done: * Support for out of source builds (this is still suspect)
* Add header files to MSVC UI for exiv2lib (and changed exiv2bin->exiv2 and exiv2->exiv2lib)
* Searching better for expat, zlib and iconv
* write FindLibexiv2.cmake (Thank you, Gilles)
* Builds and passes the test suite on 2005/32, 2008/64, Mac-Lion/64/Makefiles and Ubuntu/12.04/32bit
@ -16,7 +18,7 @@ Done: * Add header files to MSVC UI for exiv2lib (and changed exiv2bin->exiv2 an
Robin Mills
robin@clanmills.com
2012-06-05
2012-06-09
Inherited from Gilles Caulier <caulier dot gilles at gmail dot com>:

View File

@ -207,7 +207,6 @@ IF( EXIV2_ENABLE_PNG )
if ( EXIV2_ENABLE_SHARED )
TARGET_LINK_LIBRARIES( exiv2lib optimized ${ZLIB_LIBRARIES} debug ${ZLIB_LIBRARIES}d )
else()
# link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../zlib-1.2.7/$(ConfigurationName))
TARGET_LINK_LIBRARIES( exiv2lib optimized zlibstatic.lib debug zlibstaticd.lib )
endif()
ELSE()
@ -225,26 +224,47 @@ IF( ICONV_FOUND )
ENDIF( ICONV_FOUND )
IF (MSVC )
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
PRE_BUILD
COMMAND if NOT exist ..\\include mkdir ..\\include\r\nif NOT exist ..\\include\\exiv2 (\r\nmkdir ..\\include\\exiv2\r\ncopy /y ..\\src\\*.h ..\\include\\exiv2\r\ncopy /y ..\\src\\*.hpp ..\\include\\exiv2\r\n)
)
if (OUT_OF_SOURCE)
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
PRE_BUILD
COMMAND set S=$(SolutionDir)..\\src\nset I=$(SolutionDir)include\nset E=%I%\\exiv2\nif NOT exist %I% mkdir %I%\nif NOT exist %E% mkdir %E%\ncopy /y %S%\\*.h %E%\ncopy /y %S%\\*.hpp %E%
)
else()
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
PRE_BUILD
COMMAND set S=$(SolutionDir)src\nset I=$(SolutionDir)include\nset E=%I%\\exiv2\nif NOT exist %I% mkdir %I%\nif NOT exist %E% mkdir %E%\ncopy /y %S%\\*.h %E%\ncopy /y %S%\\*.hpp %E%
)
endif()
ENDIF()
##
# copy zlib and expat dlls to output directory if necessary
IF ( MSVC AND EXIV2_ENABLE_SHARED )
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
POST_BUILD
COMMAND copy /y $(SolutionDir)\\..\\expat-2.1.0\\$(ConfigurationName)\\*.dll $(SolutionDir)\\bin\\${P_DIR}\\${T_DIR}\\$(ConfigurationName)
)
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
POST_BUILD
COMMAND copy /y $(SolutionDir)\\..\\zlib-1.2.7\\$(ConfigurationName)\\*.dll $(SolutionDir)\\bin\\${P_DIR}\\${T_DIR}\\$(ConfigurationName)
)
if (OUT_OF_SOURCE)
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
POST_BUILD
COMMAND copy /y $(SolutionDir)..\\..\\${E}\\$(ConfigurationName)\\*.dll $(SolutionDir)\\bin\\${P_DIR}\\${T_DIR}\\$(ConfigurationName)
)
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
POST_BUILD
COMMAND copy /y $(SolutionDir)..\\..\\${Z}\\$(ConfigurationName)\\*.dll $(SolutionDir)\\bin\\${P_DIR}\\${T_DIR}\\$(ConfigurationName)
)
else()
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
POST_BUILD
COMMAND copy /y $(SolutionDir)..\\${E}\\$(ConfigurationName)\\*.dll $(SolutionDir)\\bin\\${P_DIR}\\${T_DIR}\\$(ConfigurationName)
)
ADD_CUSTOM_COMMAND(
TARGET exiv2lib
POST_BUILD
COMMAND copy /y $(SolutionDir)..\\${Z}\\$(ConfigurationName)\\*.dll $(SolutionDir)\\bin\\${P_DIR}\\${T_DIR}\\$(ConfigurationName)
)
endif()
ENDIF()
INSTALL( TARGETS exiv2lib ${INSTALL_TARGET_STANDARD_ARGS} )