# This CMakeLists.txt file lives in the main folder cmake_minimum_required(VERSION 3.10) project(Example3) # This defines a switch that we can pass to cmake at invocation time. # mylib library will only built if this switch is ON option(USE_MYLIB "Use mylib functions" ON) # We will use Example3_Config.h to let our program know if USE_MYLIB # is defined. This way the program can be built to use mylib when # it is available. configure_file(Example3_Config.h.in Example3_Config.h) if(USE_MYLIB) # Includes subfolder that contains the library add_subdirectory(mylib) endif() # Includes subfolder that contains the program files that will use the library add_subdirectory(prog)