How to generate new project via CMake with iMSTK

Dear,sir or madam,for purpose of newly building a project to attempt to write myself codes, I have built xxx.cpp and CMakeLists.txt. However, it’s unclear that how to write the commands in the CMakeLists.txt.
I have writed it just as below, but it doesn’t work.Would you have any advices?

cmake_minimum_required(VERSION 3.9)

project(Controlproject1)

FIND_PACKAGE(iMSTK REQUIRED)

add_executable(${PROJECT_NAME} test1.cpp)
target_link_libraries(${PROJECT_NAME})

You can checkout this project as an example. imstkexternalprojecttemplate which is tested continuously. https://gitlab.kitware.com/iMSTK/imstkexternalprojecttemplate/-/blob/master/iMSTKProject/CMakeLists.txt

You may use:

find_package(iMSTK REQUIRED)

To locate the package. Cmake’s iMSTK_DIR should be set to the imstk build directory/innerbuild. Or this path on your system path.

After find package is called you may use cmake’s target_link_libraries to iMSTK targets (this links and includes). Here’s a full list of current libraries:

target_link_libraries(TemplateInnerProject PUBLIC
	imstk::Common
	imstk::Geometry
	imstk::DataStructures
	imstk::Devices
	imstk::FilteringCore
	imstk::Filtering
	imstk::Materials
	imstk::MeshIO
	imstk::GeometryMappers
	imstk::Solvers
	imstk::DynamicalModels
	imstk::Animation
	imstk::CollisionDetection
	imstk::SceneEntities
	imstk::CollisionHandling
	imstk::Controllers
	imstk::Scene
	imstk::RenderingCore
	imstk::RenderingVTK
	imstk::ViewerCore
	imstk::ViewerVTK
	imstk::SimulationManager)

Great! A useful advice.Please accept my heartfelt thanks.

Recently,I try to generate new project in another computer with iMSTK-v5.0.0. Just like the process of my laptop,I write the CMakeLisits.txt and .cpp file.However,I can’t generate the .sln via CMake,for it can’t find the ETD2XX_DIR automatically.And I have searched the FTD2XXConfig.cmake or ftd2xx-config.cmake files in the computer, it doesn’t exist at all.What should I do to solve the problem?Does my CMakeLisits.txt exist errors?


cmake_minimum_required(VERSION 3.5.1)

project(TemplateInnerProject)

file(GLOB FILES *.cpp *.h)

Find all of TemplateInnerProject dependencies

find_package(iMSTK REQUIRED)

Build an executable

add_executable(TemplateInnerProject WIN32 ${FILES})

#-----------------------------------------------------------------------------

Link libraries to executable

#-----------------------------------------------------------------------------
set(DEPENDS
imstk::Animation
imstk::CollisionDetection
imstk::CollisionHandling
imstk::Common
imstk::Constraints
imstk::Controllers
imstk::DataStructures
imstk::Devices
imstk::DynamicalModels
imstk::Filtering
imstk::FilteringCore
imstk::Geometry
imstk::GeometryMappers
imstk::Materials
imstk::MeshIO
imstk::Rendering
imstk::Scene
imstk::SceneEntities
imstk::SimulationManager
imstk::Solvers
imstk::Testing)

target_link_libraries(TemplateInnerProject PUBLIC
${DEPENDS})

Install to CMAKE_INSTALL_PREFIX/bin

install(TARGETS TemplateInnerProject DESTINATION bin)

if(WIN32 AND MSVC)
# Set to run the exe from the install bin rather than the one in build directory
set_property(TARGET TemplateInnerProject PROPERTY VS_DEBUGGER_WORKING_DIRECTORY “${CMAKE_INSTALL_PREFIX}/bin”)

# Turn off console in release mode, fix win entry point
	set_target_properties(TemplateInnerProject PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
	set_target_properties(TemplateInnerProject PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
	set_target_properties(TemplateInnerProject PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:mainCRTStartup")
	# Enable parallel compilation for msvc
	add_definitions(/MP)
endif()

FTD2XX was removed from latest master branch of iMSTK as nothing actually used it (old dependency). Probably just some old cmake stuff. I’d recommend clearing the build directory and performing a clean build to be sure.

Okay,I’ll try it,thanks.