Skip to content

Commit

Permalink
Conan package vtx_io
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Nov 8, 2023
1 parent 7886d19 commit ff927d9
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 26 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/cmake_io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ jobs:
uses: turtlebrowser/[email protected]

- name: Create default profile
run: conan profile detect --force
run: conan profile detect

- name: Configure packages
- name: Create packages
working-directory: ${{env.CMAKELISTS_DIR}}
run: |
conan editable add .
conan editable add chemfiles
conan editable add ${{github.workspace}}/lib/util
conan editable add ${{github.workspace}}/lib/core
conan create ../util --build=missing --settings=compiler.cppstd=20
conan create ../core --build=missing --settings=compiler.cppstd=20
conan create chemfiles --build=missing
conan create . --build=missing --settings=compiler.cppstd=20
- name: Build
- name: Build tests
working-directory: ${{env.CMAKELISTS_DIR}}
run: conan build test --build=missing --build=editable --settings=compiler.cppstd=20
run: conan build test --build=missing --settings=compiler.cppstd=20

- name: Test
working-directory: ${{env.CMAKELISTS_DIR}}
Expand Down
16 changes: 10 additions & 6 deletions lib/io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
message("vtx_io")
cmake_minimum_required(VERSION 3.23)
include(../util/cmake/configure-target.cmake)
include(cmake/configure-target.cmake)
project(vtx_io)

find_package(vtx_util CONFIG REQUIRED)
find_package(vtx_core CONFIG REQUIRED)
find_package(chemfiles CONFIG REQUIRED)

file(GLOB_RECURSE HEADERS include/*)
file(GLOB_RECURSE SOURCES src/*)

add_library(vtx_io STATIC ${HEADERS} ${SOURCES})
configureTarget(vtx_io)
target_include_directories(vtx_io PUBLIC include)

file(GLOB_RECURSE HEADERS include/*)
file(GLOB_RECURSE SOURCES src/*)
target_sources(vtx_io
PRIVATE ${SOURCES}
PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS include FILES ${HEADERS})

target_link_libraries(vtx_io PRIVATE vtx_util::vtx_util)
target_link_libraries(vtx_io PRIVATE vtx_core::vtx_core)
target_link_libraries(vtx_io PRIVATE chemfiles::chemfiles)
target_link_libraries(vtx_io PRIVATE chemfiles::chemfiles)

install(TARGETS vtx_io FILE_SET public_headers)
2 changes: 1 addition & 1 deletion lib/io/chemfiles
Submodule chemfiles updated 1 files
+3 −4 conanfile.py
19 changes: 19 additions & 0 deletions lib/io/cmake/configure-target.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function(configureTarget p_target)
if(CMAKE_COMPILER_IS_GNUCC)
target_compile_options(${p_target} PRIVATE "-Wpedantic")
target_compile_options(${p_target} PRIVATE "-Wall")
elseif(MSVC)
# General.
target_compile_options(${p_target} PRIVATE "/W3") # Warning level 3.
target_compile_options(${p_target} PRIVATE "/WX") # Warnings as errors.
target_compile_options(${p_target} PRIVATE "/MP") # Multicore compilation.
target_compile_options(${p_target} PRIVATE "/sdl") # Additional Security Checks.
target_compile_options(${p_target} PRIVATE "/utf-8")
target_compile_options(${p_target} PRIVATE "/fp:fast") # Floating Point Model.
# Optimization.
target_compile_options(${p_target} PRIVATE "$<$<CONFIG:Release>:/O2>")
target_compile_options(${p_target} PRIVATE "$<$<CONFIG:Release>:/Ob2>")
target_compile_options(${p_target} PRIVATE "$<$<CONFIG:Release>:/Ot>")
target_compile_options(${p_target} PRIVATE "$<$<CONFIG:Release>:/Oi>")
endif()
endfunction()
68 changes: 68 additions & 0 deletions lib/io/cmake/qt_helper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
find_package(Qt6 COMPONENTS Core REQUIRED)

# get absolute path to qmake, then use it to find windeployqt executable

get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)

function(win_deploy_qt target)

# POST_BUILD step
# - after build, we have a bin/lib for analyzing qt dependencies
# - we run windeployqt on target and deploy Qt libs

if (MSVC)
string(APPEND CONFIG_FLAG
"$<IF:$<CONFIG:Debug>,"
"--debug,"
"--release"
">")
else()
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
if (BUILD_TYPE STREQUAL debug)
string(APPEND CONFIG_FLAG "--" BUILD_TYPE )
else()
string(APPEND CONFIG_FLAG "--release" )
endif()
endif()

add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${_qt_bin_dir}/windeployqt.exe"
--verbose 2
"${CONFIG_FLAG}"
--no-translations
--no-opengl-sw
--no-system-d3d-compiler
--libdir $<TARGET_FILE_DIR:${target}>
--plugindir $<TARGET_FILE_DIR:${target}>
\"$<TARGET_FILE:${target}>\"
COMMENT "Deploying Qt libraries using windeployqt for compilation target '${target}' ..."

# TODO : Check if usefull ?
if(!MSVC)
qt_import_plugins(${target} INCLUDE Qt::QMinimalIntegrationPlugin)
endif()

)
endfunction()

function (configure_qt)

set(CMAKE_AUTOMOC ON PARENT_SCOPE)
set(CMAKE_AUTORCC ON PARENT_SCOPE)
set(CMAKE_AUTOUIC ON PARENT_SCOPE)
set(CMAKE_AUTOUIC_SEARCH_PATHS "asset/qt/forms" PARENT_SCOPE)
#set(CMAKE_AUTOGEN_TARGETS_FOLDER "autogen")
set_property(GLOBAL PROPERTY USE_FOLDERS ON PARENT_SCOPE)
set(CMAKE_INCLUDE_CURRENT_DIR ON PARENT_SCOPE)
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)

endfunction()


function (apply_qt_options target)

set_property(TARGET ${target} PROPERTY AUTOUIC_OPTIONS "--no-autoconnection")
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)

endfunction()
2 changes: 1 addition & 1 deletion lib/io/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class VTXIORecipe(ConanFile):

generators = "CMakeDeps", "CMakeToolchain"

#exports_sources = "CMakeLists.txt", "src/*", "include/*"
exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/*"

def requirements(self):
self.requires("vtx_util/1.0")
Expand Down
10 changes: 2 additions & 8 deletions lib/io/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
message("vtx_io_test")
cmake_minimum_required(VERSION 3.23)
include(../cmake/configure-target.cmake)
project(vtx_io_test)

set(GIT_URL_CHEMFILES https://github.com/VTX-Molecular-Visualization/chemfiles.git)
set(GIT_TAG_CHEMFILES master)
include(FetchContent)
FetchContent_Declare(chemfiles GIT_REPOSITORY ${GIT_URL_CHEMFILES} GIT_TAG ${GIT_TAG_CHEMFILES})
FetchContent_MakeAvailable(chemfiles)

find_package(vtx_util CONFIG REQUIRED)
find_package(vtx_core CONFIG REQUIRED)
find_package(vtx_io CONFIG REQUIRED)
find_package(Catch2 REQUIRED)

add_executable(vtx_io_test src/main.cpp)
configureTarget(vtx_io_test)

target_link_libraries(vtx_io_test PRIVATE vtx_util::vtx_util)
target_link_libraries(vtx_io_test PRIVATE vtx_core::vtx_core)
target_link_libraries(vtx_io_test PRIVATE vtx_io::vtx_io)
target_link_libraries(vtx_io_test PRIVATE chemfiles)
target_link_libraries(vtx_io_test PRIVATE Catch2::Catch2WithMain)

include(CTest)
include(Catch)
catch_discover_tests(vtx_io_test)

# Copy data.
add_custom_target(vtx_io_test_copy_data ALL COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data $<TARGET_FILE_DIR:vtx_io_test>/data)
add_dependencies(vtx_io_test vtx_io_test_copy_data)
2 changes: 0 additions & 2 deletions lib/util/test/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ class VTXUtilTestConan(ConanFile):

generators = "CMakeToolchain", "CMakeDeps"

exports_sources = "src/*"

def requirements(self):
self.requires("vtx_util/1.0")
self.requires("catch2/3.4.0")
Expand Down

0 comments on commit ff927d9

Please sign in to comment.