cmake_minimum_required(VERSION 3.13 FATAL_ERROR) PROJECT(StructuredGrid) #----------------------------------------------------------------------------- # We will enforce an out of source build. STRING(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}" "${${PROJECT_NAME}_BINARY_DIR}" INSOURCE) if(INSOURCE) MESSAGE(FATAL_ERROR "${PROJECT_NAME} requires an out of source build.\n" "Please create a separate binary directory and run CMake there.") endif(INSOURCE) #----------------------------------------------------------------------------- # Compile options # - used when compiling targets from the current directory and below. # if (MSVC) # # Warning level 4, add /WX for all warnings as errors. # add_compile_options(/W4) # else() # # Lots of warnings, add -werror for all warnings as errors. # add_compile_options(-Wall -Wextra -pedantic) # endif() #----------------------------------------------------------------------------- # Set the C++ Standard. # Supported values are 98, 11, 14, 17, and 20. set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Enable this if you need -std=c++14 instead of -std=g++14 for gcc compilers. # This must be set before the target-definition (add_library or add_executable). #set(CMAKE_CXX_EXTENSIONS OFF) #----------------------------------------------------------------------------- # Output directories. set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.") find_package(VTK COMPONENTS CommonColor CommonCore CommonDataModel IOXML RenderingAnnotation RenderingCore # These modules are suggested since they implement an existing module. # Uncomment those you need. InteractionStyle # implements VTK::RenderingCore # RenderingFreeType # implements VTK::RenderingCore RenderingOpenGL2 # implements VTK::RenderingCore # RenderingUI # implements VTK::RenderingCore ) message (STATUS "VTK_VERSION: ${VTK_VERSION}") # Source files set( Srcs StructuredGrid.cxx ) # Include files set( Incs ) add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${Srcs} ${Incs} ) target_link_libraries(${PROJECT_NAME} PRIVATE ${VTK_LIBRARIES}) # vtk_module_autoinit is needed vtk_module_autoinit( TARGETS ${PROJECT_NAME} MODULES ${VTK_LIBRARIES} ) #----------------------------------------------------------------------------- # Set compiler and linker flags for a single target with # target_compile_options and target_link_options. if (MSVC) # Warning level 4, add /WX for all warnings as errors. target_compile_options(${PROJECT_NAME} PRIVATE /W4) else() # Lots of warnings, add -werror for all warnings as errors. target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -pedantic) endif()