# CMake Error: export requires C++ standard to be set for target 'mylib'

- **ID:** `cmake/export-requires-cpp-standard`
- **Domain:** cmake
- **Category:** build_error
- **Error Code:** `CMP0086`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The EXPORT command requires that the target has a CXX_STANDARD property set, but the target lacks it, often due to missing target_compile_features or CMAKE_CXX_STANDARD.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMake 3.24 | active | — | — |
| CMake 3.28 | active | — | — |
| CMake 3.30 | active | — | — |

## Workarounds

1. **Add target_compile_features(mylib PUBLIC cxx_std_17) before export command** (85% success)
   ```
   Add target_compile_features(mylib PUBLIC cxx_std_17) before export command
   ```
2. **Set CXX_STANDARD property explicitly on the target: set_target_properties(mylib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)** (90% success)
   ```
   Set CXX_STANDARD property explicitly on the target: set_target_properties(mylib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
   ```
3. **Use cmake_policy(SET CMP0086 NEW) to relax the check if the target already has C++ standard from dependencies** (75% success)
   ```
   Use cmake_policy(SET CMP0086 NEW) to relax the check if the target already has C++ standard from dependencies
   ```

## Dead Ends

- **Set CMAKE_CXX_STANDARD in CMakeLists.txt after add_library** — Setting CMAKE_CXX_STANDARD globally may not propagate to exported targets if not set before the target definition. (50% fail)
- **Add 'set(CMAKE_CXX_STANDARD 17)' without target_compile_features** — The export check specifically looks for target_compile_features or explicit CXX_STANDARD property on the target; global variable may be ignored. (60% fail)
- **Use INTERFACE property instead of PUBLIC for compile features** — INTERFACE properties are not sufficient for export; they must be PUBLIC or PRIVATE to be visible. (70% fail)
