build system updates
This commit is contained in:
parent
d1960506ac
commit
b2c3508e8f
@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.7.2)
|
cmake_minimum_required(VERSION 3.7.2)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
include(Colours)
|
include(Colours)
|
||||||
include(Platform)
|
include(Platform)
|
||||||
|
|
||||||
@ -37,7 +37,8 @@ http://tclap.sourceforge.net and put the headers in ./include
|
|||||||
(wink, nudge)")
|
(wink, nudge)")
|
||||||
endif(NOT TCLAP_FOUND)
|
endif(NOT TCLAP_FOUND)
|
||||||
|
|
||||||
include(LavaTargets)
|
#include(LavaTargets)
|
||||||
|
include(Binaries)
|
||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in"
|
configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in"
|
||||||
@ -45,16 +46,17 @@ configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in"
|
|||||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
|
||||||
set(src "${CMAKE_SOURCE_DIR}/src")
|
set(src "${CMAKE_SOURCE_DIR}/src")
|
||||||
|
|
||||||
lava_create_gutlib(
|
build_library(TARGET libcellar
|
||||||
SUBDIRS bottles config launch paths
|
SUBDIRS bottles config launch paths
|
||||||
DEPENDS cog)
|
DEPENDS cog)
|
||||||
|
set_target_properties(libcellar PROPERTIES PREFIX "")
|
||||||
|
|
||||||
lava_create_executable(TARGET cellar
|
build_executable(TARGET cellar
|
||||||
SUBDIRS core help
|
SUBDIRS core help
|
||||||
LIBRARIES gutlib Boost::filesystem Boost::system
|
LIBRARIES libcellar Boost::filesystem Boost::system
|
||||||
DEPENDS cog)
|
DEPENDS cog)
|
||||||
|
|
||||||
install(TARGETS cellar gutlib
|
install(TARGETS cellar libcellar
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
LIBRARY DESTINATION lib/cellar
|
LIBRARY DESTINATION lib/cellar
|
||||||
ARCHIVE DESTINATION share/cellar)
|
ARCHIVE DESTINATION share/cellar)
|
||||||
|
82
cmake/Binaries.cmake
Executable file
82
cmake/Binaries.cmake
Executable file
@ -0,0 +1,82 @@
|
|||||||
|
include(GenerateExportHeader)
|
||||||
|
|
||||||
|
link_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
set(BUILD_SHARED_LIBS ON)
|
||||||
|
if (MSVC)
|
||||||
|
add_compile_options("/utf-8")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(build_library)
|
||||||
|
set(multiValueArgs SUBDIRS DEPENDS LIBRARIES)
|
||||||
|
set(oneValueArgs TARGET)
|
||||||
|
cmake_parse_arguments(build_library "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
set(target ${build_library_TARGET})
|
||||||
|
set(targetsources)
|
||||||
|
foreach(subdir ${build_library_SUBDIRS})
|
||||||
|
set(found_files)
|
||||||
|
#file(GLOB_RECURSE found_files RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/src/${subdir}/*.cpp")
|
||||||
|
cog_sources("src/${subdir}/*.cpp" found_files)
|
||||||
|
set(targetsources ${targetsources} ${found_files})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if (MSVC AND EXISTS "${CMAKE_SOURCE_DIR}/res/${target}.rc")
|
||||||
|
set(targetsources ${targetsources} "res/${target}.rc")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(${target} SHARED ${targetsources})
|
||||||
|
if (MSVC)
|
||||||
|
set_target_properties(${target} PROPERTIES PREFIX "")
|
||||||
|
set_target_properties(${target} PROPERTIES LINK_FLAGS "/MAP")
|
||||||
|
GENERATE_EXPORT_HEADER(${target}
|
||||||
|
BASE_NAME ${target}
|
||||||
|
EXPORT_MACRO_NAME ${target}_EXPORT
|
||||||
|
EXPORT_FILE_NAME include/${target}_Export.h
|
||||||
|
STATIC_DEFINE ${target}_BUILT_AS_STATIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (build_library_LIBRARIES)
|
||||||
|
foreach (library ${build_library_LIBRARIES})
|
||||||
|
target_link_libraries(${target} ${library})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (build_library_DEPENDS)
|
||||||
|
add_dependencies(${target} ${build_library_DEPENDS})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(build_executable)
|
||||||
|
set(multiValueArgs SUBDIRS DEPENDS LIBRARIES)
|
||||||
|
set(oneValueArgs TARGET)
|
||||||
|
cmake_parse_arguments(build_executable "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
set(target ${build_executable_TARGET})
|
||||||
|
set(targetsources)
|
||||||
|
foreach(subdir ${build_executable_SUBDIRS})
|
||||||
|
set(found_files)
|
||||||
|
#file(GLOB_RECURSE found_files RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/src/${subdir}/*.cpp")
|
||||||
|
cog_sources("src/${subdir}/*.cpp" found_files)
|
||||||
|
set(targetsources ${targetsources} ${found_files})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if (MSVC AND EXISTS "${CMAKE_SOURCE_DIR}/res/${target}.rc")
|
||||||
|
set(targetsources ${targetsources} "res/${target}.rc")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(${target} ${targetsources})
|
||||||
|
if (MSVC)
|
||||||
|
# tells MSVC to use int main() but still hide the console window
|
||||||
|
set_target_properties(${target} PROPERTIES LINK_FLAGS "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (build_executable_LIBRARIES)
|
||||||
|
foreach (library ${build_executable_LIBRARIES})
|
||||||
|
target_link_libraries(${target} ${library})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (build_executable_DEPENDS)
|
||||||
|
add_dependencies(${target} ${build_executable_DEPENDS})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
@ -1,4 +1,4 @@
|
|||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
set(PLATFORM_FOREIGN_ENV FALSE)
|
set(PLATFORM_FOREIGN_ENV FALSE)
|
Loading…
x
Reference in New Issue
Block a user