Git Product home page Git Product logo

Comments (10)

kzampog avatar kzampog commented on May 18, 2024 4

I managed to compile the lib and examples in VS 2017. I did the following:

  1. Just configuring Eigen with CMake appears to make it discoverable by other projects via find_package.
  2. Same for Pangolin. It downloaded its dependencies (git required) and built without issues as a static lib (default config).
  3. The following CMakeLists.txt for cilantro seems to more or less work. I basically disabled install commands like @adishavit suggested and forced static CRT or it would not link.
cmake_minimum_required(VERSION 2.8)
project(cilantro)

# Build setup

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "/O2")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "/O2")

list(APPEND FLAG_VARS
    CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
    CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
)

foreach(FLAG_VAR ${FLAG_VARS})
    string(REGEX REPLACE "/MD" "/MT" NEW_FLAGS "${${FLAG_VAR}}")
    set(${FLAG_VAR} "${NEW_FLAGS}" CACHE STRING "" FORCE)
endforeach()

# Packages

find_package(Eigen3 REQUIRED)
find_package(Pangolin REQUIRED)
# find_package(OpenMP)
# if (OPENMP_FOUND)
#     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
#     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# endif()

set(OTHER_INCLUDES ${EIGEN3_INCLUDE_DIRS} ${Pangolin_INCLUDE_DIRS})

include_directories(include)
include_directories(${OTHER_INCLUDES})

# Build library

file(GLOB_RECURSE 3rd_src ${CMAKE_SOURCE_DIR}/src/3rd_party/*.c ${CMAKE_SOURCE_DIR}/src/3rd_party/*.cpp)
file(GLOB lib_src ${CMAKE_SOURCE_DIR}/src/*.cpp)

add_library(${PROJECT_NAME} STATIC ${3rd_src} ${lib_src})
target_link_libraries(${PROJECT_NAME} ${Pangolin_LIBRARIES})

# Build examples

option(BUILD_EXAMPLES "Build small example apps" ON)
if(BUILD_EXAMPLES)
    file(GLOB example_files RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/examples/*.cpp)
    foreach(example_file ${example_files})
        get_filename_component(example_name ${example_file} NAME_WE)
        add_executable(${example_name} ${example_file})
        target_link_libraries(${example_name} ${PROJECT_NAME} ${Pangolin_LIBRARIES})
    endforeach(example_file ${example_files})
endif()

# Package config files

file(REMOVE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
export(TARGETS ${PROJECT_NAME} APPEND FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")

set(CMAKECONFIG_INSTALL_DIR lib/cmake/${PROJECT_NAME})
file(RELATIVE_PATH REL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}/include")

# Build tree config
set(EXPORT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake @ONLY IMMEDIATE)

# Install tree config
set(EXPORT_INCLUDE_DIR "\${PROJECT_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake @ONLY)

# Add package to CMake package registry for use from the build tree
option(EXPORT_${PROJECT_NAME} "Export ${PROJECT_NAME} package for use by other software" ON)
if(EXPORT_${PROJECT_NAME})
    export(PACKAGE ${PROJECT_NAME})
endif()

# Install target

# install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
# install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)

# install(FILES "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" DESTINATION ${CMAKECONFIG_INSTALL_DIR})
# install(EXPORT ${PROJECT_NAME}Targets DESTINATION ${CMAKECONFIG_INSTALL_DIR})

# # Uninstall target

# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
# add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

Using the above, everything compiled and ran. I encountered 2 issues:

  1. OpenMP is not enabled and the source must be updated for it to work (change indices to signed type because VS still only supports OpenMP 2.0).
  2. Keyboard and mouse input when spawning multiple Visualizer windows is buggy.

I will reorganize the structure and properly revise CMakeLists at some point! :)

from cilantro.

kzampog avatar kzampog commented on May 18, 2024 3

It seems that <algorithm> is included by <Eigen/Core> (which is implicitly included pretty much everywhere), so you might be getting errors because of Eigen not having been found. Please let us know whether that is the case, so we can investigate.

Making the visualization stuff optional makes a lot of sense and I do plan to implement it! :)

from cilantro.

kzampog avatar kzampog commented on May 18, 2024 1

I added the missing M_PI defines for now. I'll try to get a VS setup some time soon and see what I could do from there.

Thanks for the feedback!

from cilantro.

Algomorph avatar Algomorph commented on May 18, 2024

@adishavit , it's a CMake project, so, as long as you can build Eigen & Pangolin (which are also both cross-platform), I don't see why not.

from cilantro.

adishavit avatar adishavit commented on May 18, 2024

from cilantro.

kzampog avatar kzampog commented on May 18, 2024

I don't have a Visual Studio installation handy to test, but my guess is that it should. Feel free to share your results and/or any needed updates!

from cilantro.

adishavit avatar adishavit commented on May 18, 2024

Yeah - it isn't as smooth as I had hoped.
Some missing includes (e.g. <algorithm> for std::min) and the Eigen CMake dependency finders are not working well.
Also, it needs GLEW and all the rest of the Pangolin dependencies.

It would actually great if display dependencies were optional - so one can choose to only use the algorithms without visualization.

from cilantro.

Algomorph avatar Algomorph commented on May 18, 2024

@kzampog , I think adding the missing headers should be a one-commit fix.
@adishavit , perhaps you can make a new issue with the feature request for optional visualization compilation?

from cilantro.

adishavit avatar adishavit commented on May 18, 2024

I kinda of gave up after spending too long on this.
I may get back to it.
But the things I did need to do were:

  1. Remove the CMake install commands. They just fail.
-install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
-install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
+# install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
+# install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
 
-install(FILES "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" DESTINATION ${CMAKECONFIG_INSTALL_DIR})
-install(EXPORT ${PROJECT_NAME}Targets DESTINATION ${CMAKECONFIG_INSTALL_DIR})
+# install(FILES "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" DESTINATION ${CMAKECONFIG_INSTALL_DIR})
+# install(EXPORT ${PROJECT_NAME}Targets DESTINATION ${CMAKECONFIG_INSTALL_DIR})
  1. Add M_PI to include/cilantro/connected_component_segmentation.hpp and src/iterative_closest_point.cpp
+#ifndef M_PI
+#define M_PI       3.14159265358979323846   // pi
+#endif
  1. Added NOMINMAX preprocessor to Windows builds.

from cilantro.

mastrogiorgis avatar mastrogiorgis commented on May 18, 2024

Hi,
Is there any update re the VS version?
Many thanks,
G

from cilantro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.