zoukankan      html  css  js  c++  java
  • 使用cmake编译luabind

    编写了一下cmakelists.txt文件

    根目录

    cmake_minimum_required(VERSION 2.8)
    project (Test)

    add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4819 /MTd" )

    if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
    MESSAGE( "64 bits compiler detected" )
    SET( EX_PLATFORM 64 )
    SET( EX_PLATFORM_NAME "x64" )
    else( )
    MESSAGE( "32 bits compiler detected" )
    SET( EX_PLATFORM 32 )
    SET( EX_PLATFORM_NAME "x86" )
    endif( )

    IF( EX_PLATFORM EQUAL 64 )
    MESSAGE( "Outputting to lib64 and bin64" )

    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib64)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib64)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin64)
    ELSE( )
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
    ENDIF( )

    include_directories ("${PROJECT_SOURCE_DIR}")
    include_directories ("E:/_codes/boost_1_55_0/boost_1_55_0")
    include_directories ("E:/Program Files/Lua/5.1/include")

    IF( EX_PLATFORM EQUAL 64 )
    ELSE( )
    link_directories ("E:/Program Files/Lua/5.1/lib")
    ENDIF( )

    set(CMAKE_MSVCIDE_RUN_PATH "E:/Program Files/Lua/5.1/lib"
    )

    set (EXTRA_LIBS ${EXTRA_LIBS} lua51.lib
    )

    if(MSVC)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819")
    endif()

    macro(copy_dll depdir dllname)
    foreach(configuration ${CMAKE_CONFIGURATION_TYPES})
    # 对应于不同的构建版本
    set(dllpath "${depdir}/bin/${configuration}/${dllname}")
    if(EXISTS ${dllpath})
    configure_file(${dllpath} ${CMAKE_BINARY_DIR}/bin/${configuration}/${dllname} COPYONLY)
    endif()
    endforeach()
    endmacro()

    macro (create_test target)
    add_test (NAME ${target} COMMAND $<TARGET_FILE:${target}>)
    #set_tests_properties(${target} PROPERTIES ENVIRONMENT "PATH=${PATH};${PATH_ENV}")
    #add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Table.h"
    # COMMAND set "PATH=${PATH_ENV};%PATH%"
    # COMMAND $<TARGET_FILE:${target}> "${CMAKE_CURRENT_BINARY_DIR}/Table.h"
    # DEPENDS $<TARGET_FILE:${target}>)
    endmacro (create_test)

    ENABLE_TESTING()

    add_subdirectory (src)
    add_subdirectory (test)

    srfcMulu 

    cmake_minimum_required(VERSION 2.8)

    #include_directories ("${CMAKE_CURRENT_LIST_DIR}/include")

    add_library(luabind SHARED
    class.cpp
    class_info.cpp
    class_registry.cpp
    class_rep.cpp
    create_class.cpp
    error.cpp
    exception_handler.cpp
    function.cpp
    inheritance.cpp
    link_compatibility.cpp
    object_rep.cpp
    open.cpp
    pcall.cpp
    scope.cpp
    stack_content_by_name.cpp
    weak_ref.cpp
    wrapper_base.cpp
    )
    target_compile_definitions(luabind PRIVATE LUABIND_DYNAMIC_LINK LUABIND_BUILDING)
    target_link_libraries (luabind ${EXTRA_LIBS})

    test目录

    cmake_minimum_required(VERSION 2.8)

    #include_directories ("${CMAKE_CURRENT_LIST_DIR}/include")


    add_executable(testHello
    #benchmark.cpp
    main.cpp
    test_abstract_base.cpp

    )
    target_compile_definitions(testHello PRIVATE LUABIND_DYNAMIC_LINK)
    create_test(testHello)
    target_link_libraries (testHello luabind ${EXTRA_LIBS})

    file(GLOB_RECURSE SRC_CORE test*.cpp)
    foreach(the_file ${SRC_CORE})
    get_filename_component (NAME ${the_file} NAME_WE)
    MESSAGE( "NAME " ${NAME} )

    add_executable(${NAME} main.cpp ${the_file} )
    target_compile_definitions(${NAME} PRIVATE LUABIND_DYNAMIC_LINK)
    create_test(${NAME})
    target_link_libraries (${NAME} luabind ${EXTRA_LIBS})
    endforeach(the_file)

  • 相关阅读:
    【练习】flushback基于时间的闪回查询
    【练习】审计
    【练习】新建虚拟机
    织梦安全防护教程首页被挟持、被串改、被挂马、被入侵之后如何解决?
    织梦手机站下一篇变上一篇而且还出错Request Error!
    织梦图集上传错误提示ERROR: Upload Error!
    织梦炒鸡简单3部曲修改文档标题长度限制
    织梦dede:arclist和dede:list输出每个文章的内容有多少页
    织梦后台管理模板无法正常显示模板文件列表解决方法
    织梦列表页多种属性排序[ajax]-支持select方式和降序升序切换
  • 原文地址:https://www.cnblogs.com/cutepig/p/6399841.html
Copyright © 2011-2022 走看看