Advertisement

配置代码中的参数方法:CMakeLists.txt

阅读量:

直接查阅代码,将BUILD_ROS参数传递至hello.cpp文件中。
hello.cpp的代码内容如下:

复制代码
    #include <iostream>
    int main()
    {
    #if BUILD_ROS
    	{
    		std::cout<<"hello ros"<<std::endl;
    	}
    #else
    	{
                std::cout<<"hello world"<<std::endl;
    	}
    #endif
    	return 0;
    }
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    

位于同一层级目录中的 CMakeLists.txt 文件内容为:

复制代码
    cmake_minimum_required(VERSION 2.8)
    project(demo)
    
    # set(BUILD_ROS 0)  # open ros by "cmake .. -DBUILD_ROS=1"
    
    if(${BUILD_ROS})

全部评论 (0)

还没有任何评论哟~