Commit a4138e23 authored by Alexis Girault's avatar Alexis Girault

COMP: Fix for VegaFEM on VS

All projects output directories are now common in
the top level. This commit takes care of the
CMAKE_CONFIGURATION_TYPES for Visual Studio.

With this commit the Find_XXX.cmake files do not need
HINTS anymore since all targets are built in a same
directory known to CMAKE_LIBRARY_PATH, and all headers
directories are referenced in CMAKE_INCLUDE_PATH.
parent 198ad540
......@@ -14,6 +14,92 @@ if(NOT ${PROJECT_NAME}_USE_GIT_PROTOCOL)
set(git_protocol "http")
endif()
#-----------------------------------------------------------------------------
# Output Directories
#-----------------------------------------------------------------------------
set(_sep_ "^^")
# Set directory variables
if(NOT BIN_DIR)
set(BIN_DIR bin)
endif(NOT BIN_DIR)
if(NOT LIB_DIR)
set(LIB_DIR lib)
endif(NOT LIB_DIR)
# Output directories - this is where built library and executable
# files will be placed after building but prior to install. The
# necessary variables change between single and multi configuration
# build systems, so it is necessary to handle both cases on a
# conditional basis.
if(NOT CMAKE_CONFIGURATION_TYPES)
# If we're not doing multi-configuration, just set the three main
# variables to the correct values.
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKES_BINARY_DIR}/${LIB_DIR})
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKES_BINARY_DIR}/${LIB_DIR})
endif()
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKES_BINARY_DIR}/${BIN_DIR})
endif()
list(APPEND CMAKE_OUTPUT_DIRECTORIES
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:STRING=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:STRING=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:STRING=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
)
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}${_sep_}${CMAKE_LIBRARY_PATH}")
set(CMAKE_LIBRARY_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}${_sep_}${CMAKE_LIBRARY_PATH}")
else()
# Multi-configuration is more difficult. Not only do we need to
# properly set the output directories, but we also need to
# identify the "toplevel" directory for each configuration so
# we can place files, documentation, etc. in the correct
# relative positions. Because files may be placed by CMake
# without a build target to put them in their proper relative build
# directory position using these paths, we must fully qualify them
# without using CMAKE_CFG_INTDIR.
#
# We define directories that may not be quite "standard"
# for a particular build tool - for example, native VS2010 projects use
# another directory to denote CPU type being compiled for - but CMake only
# supports multi-configuration setups having multiple configurations,
# not multiple compilers.
#
# One additional wrinkle we must watch for here is the case where
# a multi-configuration setup uses "." for its internal directory -
# if that's the case, we need to just set the various config output
# directories to the same value.
foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
set(CFG_ROOT ${CMAKE_BINARY_DIR}/${CFG_TYPE})
string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER)
if(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR})
endif()
if(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR})
endif()
if(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR})
endif()
list(APPEND CMAKE_OUTPUT_DIRECTORIES
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}:STRING=${CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}:STRING=${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}:STRING=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}
)
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}${_sep_}${CMAKE_LIBRARY_PATH}")
set(CMAKE_LIBRARY_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}${_sep_}${CMAKE_LIBRARY_PATH}")
endforeach()
endif()
#-----------------------------------------------------------------------------
# Prepare include path to fill external projects include path
#-----------------------------------------------------------------------------
set(CMAKE_INCLUDE_PATH)
#-----------------------------------------------------------------------------
# CMake global args
#-----------------------------------------------------------------------------
......@@ -26,8 +112,7 @@ list(APPEND CMAKE_CONFIG_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS}
-DCMAKE_INCLUDE_PATH:STRING=${${PROJECT_NAME}_CMAKE_INCLUDE_PATH}
-DCMAKE_LIBRARY_PATH:STRING=${${PROJECT_NAME}_CMAKE_LIBRARY_PATH}
-DCMAKE_LIBRARY_PATH:STRING=${CMAKE_LIBRARY_PATH}
)
#-----------------------------------------------------------------------------
......@@ -64,12 +149,10 @@ ExternalProject_Add( ${PROJECT_NAME}
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS
-D${PROJECT_NAME}_SUPERBUILD:BOOL=OFF
# -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
# -DBUILD_DOCUMENTATION:BOOL=${BUILD_DOCUMENTATION}
# -DBUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES}
# -DBUILD_TESTING:BOOL=${BUILD_TESTING}
${CMAKE_CONFIG_ARGS}
${CMAKE_CONFIG_OSX_ARGS}
${CMAKE_OUTPUT_DIRECTORIES}
-DCMAKE_INCLUDE_PATH:STRING=${CMAKE_INCLUDE_PATH}
${${PROJECT_NAME}_EXTERNAL_PROJECTS_PATHS}
DEPENDS ${${PROJECT_NAME}_DEPENDENCIES}
)
......@@ -5,6 +5,7 @@ include(imstkAddExternalProject)
imstk_add_external_project( Eigen
REPOSITORY ${git_protocol}://github.com/RLovelett/eigen.git
GIT_TAG e81ac4502ebbfde43a1e1761b36853d3ead47c33
#RELATIVE_INCLUDE_PATH ""
#DEPENDENCIES ""
#VERBOSE
)
......@@ -5,6 +5,7 @@ include(imstkAddExternalProject)
imstk_add_external_project( PThreads
REPOSITORY ${git_protocol}://github.com/songdongsheng/libpthread.git
GIT_TAG 38821d529407dcb0b4661c6805d7b1bf83f3204d
RELATIVE_INCLUDE_PATH "/include"
DEPENDENCIES ""
#VERBOSE
)
......@@ -21,6 +21,7 @@ imstk_add_external_project( VTK
-DModule_vtkRenderingContext2D:BOOL=ON
-DVTK_RENDERING_BACKEND:STRING=OpenGL2
-DVTK_WRAP_PYTHON:BOOL=OFF
DEPENDENCIES ""
#RELATIVE_INCLUDE_PATH ""
#DEPENDENCIES ""
#VERBOSE
)
......@@ -9,12 +9,13 @@ endif(WIN32)
include(imstkAddExternalProject)
imstk_add_external_project( VegaFEM
REPOSITORY git@gitlab.kitware.com:iMSTK/VegaFEM-CMake.git
GIT_TAG simmedtk
GIT_TAG iMSTK
CMAKE_ARGS
-DVegaFEM_ENABLE_PTHREADS_SUPPORT:BOOL=ON
-DVegaFEM_ENABLE_OpenGL_SUPPORT:BOOL=OFF
-DVegaFEM_BUILD_MODEL_REDUCTION:BOOL=OFF
-DVegaFEM_BUILD_UTILITIES:BOOL=ON
DEPENDENCIES ${VegaFEM_DEPENDENCIES}
#RELATIVE_INCLUDE_PATH ""
#VERBOSE
)
......@@ -5,6 +5,7 @@ include(imstkAddExternalProject)
imstk_add_external_project( g3log
REPOSITORY ${git_protocol}://github.com/KjellKod/g3log.git
GIT_TAG 579579962c94213a46fadbb70a996f08c19be3a2
RELATIVE_INCLUDE_PATH "/src/g3log"
#DEPENDENCIES ""
#VERBOSE
)
......@@ -15,18 +15,14 @@ if(NOT Eigen_FIND_VERSION)
set(Eigen_FIND_VERSION "${Eigen_FIND_VERSION_MAJOR}.${Eigen_FIND_VERSION_MINOR}.${Eigen_FIND_VERSION_PATCH}")
endif()
#-----------------------------------------------------------------------------
# Macro checking version
#-----------------------------------------------------------------------------
macro(_eigen_check_version)
endmacro(_eigen_check_version)
#-----------------------------------------------------------------------------
# Find path
#-----------------------------------------------------------------------------
set(Eigen_INCLUDE_DIR ${Eigen_SOURCE_DIR})
find_path(Eigen_INCLUDE_DIR
NAMES
eigen/Eigen
Eigen
)
mark_as_advanced(Eigen_INCLUDE_DIR)
#message(STATUS "Eigen_INCLUDE_DIR : ${Eigen_INCLUDE_DIR}")
......@@ -66,7 +62,7 @@ find_package_handle_standard_args(Eigen
#-----------------------------------------------------------------------------
# If missing target, create it
#-----------------------------------------------------------------------------
if(G3LOG_FOUND AND NOT TARGET Eigen)
if(Eigen_FOUND AND NOT TARGET Eigen)
add_library(Eigen INTERFACE IMPORTED)
set_target_properties(Eigen PROPERTIES
INTERFACE_LINK_LIBRARIES "${Eigen_LIBRARY}"
......
#-----------------------------------------------------------------------------
# Find path
#-----------------------------------------------------------------------------
find_path(PTHREAD_INCLUDE_DIR
NAMES
PThreads.h
HINTS
${PThreads_SOURCE_DIR}/include
)
mark_as_advanced(PTHREAD_INCLUDE_DIR)
#message(STATUS "PTHREAD_INCLUDE_DIR : ${PTHREAD_INCLUDE_DIR}")
#-----------------------------------------------------------------------------
# Find library
#-----------------------------------------------------------------------------
find_library(PTHREAD_LIBRARY
NAMES
PThreads
libPThreads
HINTS
${PThreads_DIR}
)
mark_as_advanced(PTHREAD_LIBRARY)
#message(STATUS "PTHREAD_LIBRARY : ${PTHREAD_LIBRARY}")
#-----------------------------------------------------------------------------
# Find package
#-----------------------------------------------------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PTHREAD
REQUIRED_VARS
PTHREAD_INCLUDE_DIR
PTHREAD_LIBRARY)
#-----------------------------------------------------------------------------
# If missing target, create it
#-----------------------------------------------------------------------------
if(PThreads_FOUND AND NOT TARGET Threads::Threads)
add_library(Threads::Threads INTERFACE IMPORTED)
set_target_properties(Threads::Threads PROPERTIES
INTERFACE_LINK_LIBRARIES "${PTHREAD_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${PTHREAD_INCLUDE_DIR}"
)
endif()
......@@ -3,10 +3,8 @@
#-----------------------------------------------------------------------------
find_path(g3log_INCLUDE_DIR
NAMES
g3log/g3log.hpp
g3log/logworker.hpp
HINTS
${g3log_SOURCE_DIR}/src
g3log.hpp
logworker.hpp
)
mark_as_advanced(g3log_INCLUDE_DIR)
#message(STATUS "g3log_INCLUDE_DIR : ${g3log_INCLUDE_DIR}")
......@@ -17,8 +15,6 @@ mark_as_advanced(g3log_INCLUDE_DIR)
find_library(g3log_LIBRARY
NAMES
g3logger_shared
HINTS
${g3log_DIR}
)
mark_as_advanced(g3log_LIBRARY)
#message(STATUS "g3log_LIBRARY : ${g3log_LIBRARY}")
......
macro(imstk_add_external_project extProj)
set(options VERBOSE)
set(oneValueArgs REPOSITORY GIT_TAG)
set(oneValueArgs REPOSITORY GIT_TAG RELATIVE_INCLUDE_PATH)
set(multiValueArgs CMAKE_ARGS DEPENDENCIES)
include(CMakeParseArguments)
cmake_parse_arguments(${extProj} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
......@@ -45,8 +45,6 @@ macro(imstk_add_external_project extProj)
set(${extProj}_SOURCE_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/src)
set(${extProj}_PREFIX_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/cmake)
set(${extProj}_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/build)
set(${extProj}_INCLUDE_PATH ${${extProj}_DIR}/include)
set(${extProj}_LIBRARY_PATH ${${extProj}_DIR}/library)
#-----------------------------------------------------------------------------
# Add project
......@@ -60,15 +58,13 @@ macro(imstk_add_external_project extProj)
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
LIST_SEPARATOR ${_sep_}
CMAKE_ARGS
${CMAKE_CONFIG_ARGS}
${CMAKE_CONFIG_OSX_ARGS}
${CMAKE_OUTPUT_DIRECTORIES}
${${extProj}_CMAKE_ARGS}
-DCMAKE_INCLUDE_PATH:STRING=${${extProj}_INCLUDE_PATH}
-DCMAKE_LIBRARY_PATH:STRING=${${extProj}_LIBRARY_PATH}
#-DBUILD_SHARED_LIBS:BOOL=${shared}
#-DBUILD_EXAMPLES:BOOL=OFF
#-DBUILD_TESTING:BOOL=OFF
-DCMAKE_INCLUDE_PATH:STRING=${CMAKE_INCLUDE_PATH}
DEPENDS ${${extProj}_DEPENDENCIES}
)
......@@ -98,10 +94,14 @@ macro(imstk_add_external_project extProj)
endif()
#-----------------------------------------------------------------------------
# Keep track of project path to add it in the superbuild cache
# Keep track of include path for superbuild
#-----------------------------------------------------------------------------
set(CMAKE_INCLUDE_PATH "${${extProj}_SOURCE_DIR}${${extProj}_RELATIVE_INCLUDE_PATH}^^${CMAKE_INCLUDE_PATH}")
#-----------------------------------------------------------------------------
# Keep track of build path to add it in the innerbuild cache
#-----------------------------------------------------------------------------
list( APPEND ${PROJECT_NAME}_EXTERNAL_PROJECTS_PATHS
-D${extProj}_SOURCE_DIR:PATH=${${extProj}_SOURCE_DIR}
-D${extProj}_DIR:PATH=${${extProj}_DIR}
)
endmacro()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment