| cmake_minimum_required(VERSION 3.18) |
| |
| # 设置工程名称 |
| set(PROJECT_NAME KAIZEN) |
| |
| # 设置工程版本号 |
| set(PROJECT_VERSION "1.0.0.10" CACHE STRING "默认版本号") |
| |
| # 工程定义 |
| project(${PROJECT_NAME} |
| LANGUAGES CXX C |
| VERSION ${PROJECT_VERSION} |
| ) |
| |
| # 打印开始日志 |
| message(STATUS "\n########## BEGIN_TEST_OPTION") |
| |
| ## 示例1:不赋值 |
| option(${PROJECT_NAME}_BUILD_TEST "构建测试模块") |
| |
| if (DEFINED ${PROJECT_NAME}_BUILD_TEST) |
| message(STATUS "defined KAIZEN_BUILD_TEST") |
| else() |
| message(STATUS "not defined KAIZEN_BUILD_TEST") |
| endif() |
| |
| if (${PROJECT_NAME}_BUILD_TEST) |
| message(STATUS "KAIZEN_BUILD_TEST is ON") |
| else() |
| message(STATUS "KAIZEN_BUILD_TEST is OFF") |
| endif() |
| message(STATUS "\n") |
| |
| ## 示例2:赋值为非ON、非OFF值 |
| option(${PROJECT_NAME}_BUILD_EXAMPLE "构建示例模块" AAA) |
| |
| if (DEFINED ${PROJECT_NAME}_BUILD_EXAMPLE) |
| message(STATUS "defined KAIZEN_BUILD_EXAMPLE") |
| else() |
| message(STATUS "not defined KAIZEN_BUILD_EXAMPLE") |
| endif() |
| |
| if (${PROJECT_NAME}_BUILD_EXAMPLE) |
| message(STATUS "KAIZEN_BUILD_EXAMPLE_1 is ON") |
| else() |
| message(STATUS "KAIZEN_BUILD_EXAMPLE_1 is OFF") |
| endif() |
| |
| if (${${PROJECT_NAME}_BUILD_TYPE}) |
| message(STATUS "KAIZEN_BUILD_EXAMPLE_2 is ON") |
| else() |
| message(STATUS "KAIZEN_BUILD_EXAMPLE_2 is OFF") |
| endif() |
| message(STATUS "\n") |
| |
| ## 示例3:赋值为ON |
| option(${PROJECT_NAME}_BUILD_GUI "构建视图模块" ON) |
| |
| if (DEFINED ${PROJECT_NAME}_BUILD_GUI) |
| message(STATUS "defined KAIZEN_BUILD_GUI") |
| else() |
| message(STATUS "not defined KAIZEN_BUILD_GUI") |
| endif() |
| |
| if (${PROJECT_NAME}_BUILD_GUI) |
| message(STATUS "KAIZEN_BUILD_GUI is ON") |
| else() |
| message(STATUS "KAIZEN_BUILD_GUI is OFF") |
| endif() |
| |
| # 打印结束日志 |
| message(STATUS "########## END_TEST_OPTION\n") |