Win7 + VS2015 + CMake3.6.1-GUI + Makefile 编译开源库

CMake生成Unicode版本VC工程

    Just add this line in your top CMakeLists.txt file:
    add_definitions(-DUNICODE -D_UNICODE)

        if(MSVC)
            add_definitions(-DUNICODE -D_UNICODE)
        endif()

基本配置

    配置生成库输出目录 ExportDir=F:\Develop\bin\x64
    Add Entry:
        CMAKE_INSTALL_PREFIX F:\Develop\bin\x64\xxx

# Only enable release and debug builds
IF(CMAKE_CONFIGURATION_TYPES)
  SET(CMAKE_CONFIGURATION_TYPES Release Debug )
  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
    "Reset the configurations to what we need"
    FORCE)
ENDIF()
        
if(MSVC)
    set(CMAKE_DEBUG_POSTFIX "d")
endif()

zlib-1.2.8 

    修改CMakeLists.txt, 加入字符编码
        if(MSVC)
            add_definitions(-DUNICODE -D_UNICODE)
        endif()
    配置CMAKE_INSTALL_PREFIX参数, 指定头文件及编译包Install目录. ($(ExportDir)\zlib-1.2.8)
    Config –> Generate
    打开zlib.sln进行批生成

OpenSSL-1.0.2k

    1. 编译 见《INSTALL.W64》 To build for Win64/x64
        32  $ perl Configure VC-WIN32 no-asm --prefix=$(ExportDir)\OpenSSL-1.0.2
        64  $ perl Configure VC-WIN64A no-asm --prefix=$(ExportDir)\OpenSSL-1.0.2
            > perl Configure VC-WIN64A no-asm --prefix=F:\Develop\bin\x64\OpenSSL-1.0.2
     > ms\do_win64a
     > nmake -f ms\ntdll.mak
            > nmake -f ms\ntdll.mak install
     > cd out32dll
            > ..\ms\test
    2. 环境变量设置
        OPENSSL_BASE = $(ExportDir)\OpenSSL-1.0.2
        OPENSSL_ROOT_DIR = $(ExportDir)\OpenSSL-1.0.2
    3. 包含目录
        $(OPENSSL_BASE)\include;
    4. 库目录
        $(OPENSSL_BASE)\lib;
    5. 库文件
        libeay32.lib;ssleay32.lib;

OpenSSL-1.1.0b

    1. 编译 (Win64默认为 UNICODE, 不需要加 -DUNICODE -D_UNICODE)
        32  $ perl Configure VC-WIN32 no-asm --prefix=$(ExportDir)\OpenSSL-1.1
        64  $ perl Configure VC-WIN64A no-asm --prefix=$(ExportDir)\OpenSSL-1.1
            perl Configure VC-WIN64A no-asm --prefix=F:\Develop\bin\x64\OpenSSL-1.1
            $ nmake
            $ nmake test
            $ nmake install
    2. 环境变量设置
        OPENSSL_BASE = $(ExportDir)\OpenSSL
        OPENSSL_ROOT_DIR = $(ExportDir)\OpenSSL
    3. 包含目录
        $(OPENSSL_BASE)\include;
    4. 库目录
        $(OPENSSL_BASE)\lib;
    5. 库文件
        libcrypto.lib;libssl.lib;

libpng-1.6.28

    配置CMAKE_INSTALL_PREFIX参数, 指定头文件及编译包Install目录. ($(ExportDir)\jpeg-9b)
        F:\Develop\bin\x64\libpng-1.6.28
    
        ZLIB_INCLUDE_DIR  
        ZLIB_LIBRARY_DEBUG
        ZLIB_LIBRARY_RELEASE
        ld-version-script OFF
        PNG_TESTS
    Config –> Generate
    打开zlib.sln进行批生成

jpeg-9b

    方式1: 使用CMakeLists.txt
    配置CMAKE_INSTALL_PREFIX参数, 指定头文件及编译包Install目录. ($(ExportDir)\libpng-1.6.28)
        F:\Develop\bin\x64\jpeg-9b
        LIBJPEG_SOURCE_DIR F:/Develop/libs/jpeg-9b
        
    方式2:
        0. 把Win32.mak(C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\Win32.Mak)拷贝到源文件目录
        1. Open the command prompt, change to the main directory and execute the command line
            NMAKE /f makefile.vc setup-v10
           This will move jconfig.vc to jconfig.h and makefiles to project files.
           (Note that the renaming is critical!)
        2. Open the solution file jpeg.sln, build the library project.
           (If you are using Visual Studio more recent than 2010 (v10), you'll
           probably get a message saying that the project files are being updated.)
        3. Open the solution file apps.sln, build the application projects.
        4. To perform the self-test, execute the command line
            NMAKE /f makefile.vc  test-build
        5. Move the application .exe files from `app`\Release to an
           appropriate location on your path.

tiff-4.0.7

    配置CMAKE_INSTALL_PREFIX参数, ($(ExportDir)\tiff-4.0.7)
        F:\Develop\bin\x64\tiff-4.0.7
        配置zlib, jpeg

freetype-2.7

    配置CMAKE_INSTALL_PREFIX参数, ($(ExportDir)\freetype-2.7)
        F:\Develop\bin\x64\freetype-2.7
        配置zlib

giflib-5.1.4

    配置CMAKE_INSTALL_PREFIX参数, ($(ExportDir)\giflib-5.1.4)
        F:\Develop\bin\x64\giflib-5.1.4
        配置GIFLIB_SOURCE_DIR

minizip

    配置CMAKE_INSTALL_PREFIX参数, ($(ExportDir)\minizip)
        F:\Develop\bin\x64\minizip
        ZLIB_ROOT F:\Develop\bin\x64\zlib-1.2.8

glut

    配置CMAKE_INSTALL_PREFIX参数, ($(ExportDir)\glut)
        F:\Develop\bin\x64\glut
        GLUT_SOURCE_DIR F:\Develop\GitRepos\OpenSceneGraph3rdParty\glut

libssh2-1.8.0

    修改CMakeLists.txt, 加入字符编码
        if(MSVC)
            add_definitions(-DUNICODE -D_UNICODE)
        endif()
    配置CMAKE_INSTALL_PREFIX参数, 指定头文件及编译包Install目录. ($(ExportDir)\libssh2-1.8)
        F:\Develop\bin\x64\libssh2-1.8
        关闭test,examples
    Config –> Generate
    打开 libssh2.sln
        为debug输出目标名加上d后缀
        进行批生成
        手动拷贝src/debug目录下的libssh2d.lib到lib目录

curl-7.52.1

    配置CMAKE_INSTALL_PREFIX参数, 指定头文件及编译包Install目录. ($(ExportDir)\curl-7.52.1)
        Zlib相关参数, F:/Develop/bin/x64/zlib-1.2.11
    OpenSSL相关参数, F:/Develop/bin/x64/OpenSSL-1.0.2
    OPENSSL_ROOT_DIR, F:/Develop/bin/x64/OpenSSL-1.0.2
    ENABLE_MANUAL, OFF
        BUILD_RELEASE_DEBUG_DIRS
    Config –> Generate
    打开 CURL.sln进行批生成
    拷贝 Output\lib\Release\libcurl.dll
    拷贝 Output\lib\Debug\libcurl.dll 为 libcurld.dll
    拷贝 Output\lib\Debug\libcurl.pdb 为 libcurld.pdb

curl-7_51_0

    修改CMakeLists.txt, 加入字符编码
        if(MSVC)
            add_definitions(-DUNICODE -D_UNICODE)
        endif()
    配置CMAKE_INSTALL_PREFIX参数, 指定头文件及编译包Install目录. ($(ExportDir)\curl-7_51)
        Zlib相关参数, F:/Develop/bin/x64/zlib/lib
        BUILD_RELEASE_DEBUG_DIRS
    Config –> Generate
    打开 CURL.sln进行批生成
    拷贝 Output\lib\Release\libcurl.dll
    拷贝 Output\lib\Debug\libcurl.dll 为 libcurld.dll
    拷贝 Output\lib\Debug\libcurl.pdb 为 libcurld.pdb

glew 2.0.0

    打开VC12目录下的glew.sln,升级到VC14
        设置字符集
    使用x64编译 debug, release版本
    拷贝 bin\debug(release)\x64下文件到 $(ExportDir)\glew-2.0.0\bin
    拷贝 lib\debug(release)\x64下文件到 $(ExportDir)\glew-2.0.0\lib
    拷贝 include目录到$(ExportDir)\glew-2.0.0

iconv 1.14

    按照http://www.codeproject.com/Articles/302012/How-to-Build-libiconv-with-Microsoft-Visual-Studio说明进行配置
    debug配置->常规-> 目标文件名: $(ProjectName)d
    生成后,把
        debug(release)\libiconv(d).lib拷贝到 $(ExportDir)\lib
        iconv.h拷贝到 $(ExportDir)\include
        debug(release)\libiconv(d).dll(pdb)拷贝到 $(ExportDir)\bin

libxml2-2.9.4

    将其中的iconv.h放入$(ExportDir)\bin\include目录中,将其中的libiconv.lib放入$(ExportDir)\bin\lib中,并改名为iconv.lib.(没有相应目录就新建一个)。
    修改libxml2\win32\Makefile.msvc
    POST_TAG = ""
    !if "$(DEBUG)" == "1"
    POST_TAG = "d"
    !endif
    XML_SO = $(XML_BASENAME)$(POST_TAG).dll
    XML_IMP = $(XML_BASENAME)$(POST_TAG).lib
    XML_DEF = $(XML_BASENAME).def
    XML_A = $(XML_BASENAME)$(POST_TAG)_a.lib
    XML_A_DLL = $(XML_BASENAME)$(POST_TAG)_a_dll.lib


    cscript configure.js compiler=msvc prefix=$(ExportDir)\bin  include=$(ExportDir)\bin\include lib=$(ExportDir)\bin\lib debug=yes(no)
    cscript configure.js compiler=msvc prefix=F:\Develop\bin\x64\bin include=F:\Develop\bin\x64\bin\include lib=F:\Develop\bin\x64\bin\lib debug=yes
        手工拷贝文件
    cscript configure.js compiler=msvc prefix=F:\Develop\bin\x64\bin include=F:\Develop\bin\x64\bin\include lib=F:\Develop\bin\x64\bin\lib debug=no
        nmake install

CGAL-4.9

    修改CMakeLists.txt, 加入字符编码
        if(MSVC)
            add_definitions(-DUNICODE -D_UNICODE)
        endif()
    配置CMAKE_INSTALL_PREFIX参数, 指定头文件及编译包Install目录. ($(ExportDir)\CGAL)
        F:/Develop/bin/x64/CGAL
        Zlib相关参数, F:/Develop/bin/x64/zlib/lib

 

历史:

2017-01-31: OpenSSL-1.0.2K编译
2017-02-12:

转载于:https://www.cnblogs.com/yaoyu126/p/6040119.html

你可能感兴趣的:(Win7 + VS2015 + CMake3.6.1-GUI + Makefile 编译开源库)