From 41f0cc83fea88bf0b391a7a9888750359c40e12d Mon Sep 17 00:00:00 2001 From: Thibault Lescoat Date: Tue, 7 Mar 2017 17:12:23 +0100 Subject: [PATCH] Some fixes to linux compilation --- CMakeLists.txt | 1 + cmake/bx.cmake | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa164d0..b21bec5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ option( BGFX_BUILD_TOOLS "Build bgfx tools." ON ) option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON ) option( BGFX_INSTALL "Create installation target." ON ) option( BGFX_USE_OVR "Build with OVR support." OFF ) +option( BX_AMALGAMATED "Amalgamate bx source files for faster compilation" ON ) if( NOT BX_DIR ) set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bgfx." ) diff --git a/cmake/bx.cmake b/cmake/bx.cmake index e94d116..c4da0e2 100644 --- a/cmake/bx.cmake +++ b/cmake/bx.cmake @@ -15,7 +15,12 @@ if( NOT IS_DIRECTORY ${BX_DIR} ) endif() # Grab the bx source files -file( GLOB BX_SOURCES ${BX_DIR}/src/*.cpp ) +if(BX_AMALGAMATED) + set(BX_SOURCES ${BX_DIR}/src/amalgamated.cpp) +else() + file( GLOB BX_SOURCES ${BX_DIR}/src/*.cpp ) + list(REMOVE_ITEM ${BX_DIR}/src/amalgamated.cpp) +endif() # Create the bx target add_library( bx STATIC ${BX_SOURCES} ) @@ -42,10 +47,14 @@ target_compile_definitions( bx PUBLIC "__STDC_LIMIT_MACROS" ) target_compile_definitions( bx PUBLIC "__STDC_FORMAT_MACROS" ) target_compile_definitions( bx PUBLIC "__STDC_CONSTANT_MACROS" ) -# Threads +# Additional dependencies on Unix if( UNIX AND NOT APPLE ) + # Threads find_package( Threads ) target_link_libraries( bx ${CMAKE_THREAD_LIBS_INIT} dl ) + + # Real time (for clock_gettime) + target_link_libraries( bx rt ) endif() # Put in a "bgfx" folder in Visual Studio