File tree Expand file tree Collapse file tree 3 files changed +49
-30
lines changed Expand file tree Collapse file tree 3 files changed +49
-30
lines changed Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.10)
22project (cppp-platform VERSION 1.3.0)
33
4+ option (BUILD_EXAMPLE "Build example" OFF )
5+
46# Read source files
57file (READ "${CMAKE_CURRENT_SOURCE_DIR} /src/architectures.h" ARCHITECTURES)
68file (READ "${CMAKE_CURRENT_SOURCE_DIR} /src/compilers.h" COMPILERS)
79file (READ "${CMAKE_CURRENT_SOURCE_DIR} /src/languagestandards.h" LANGUAGESTANDARDS)
810file (READ "${CMAKE_CURRENT_SOURCE_DIR} /src/platforms.h" PLATFORMS)
911
1012# Genetate header
11- configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /include/cppp/cppp-platform.h.in" "${output_includedir} /cppp/cppp-platform.h" )
13+ configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /include/cppp/cppp-platform.h.in" "${CMAKE_BINARY_DIR} /include/cppp/cppp-platform.h" )
14+
15+ # Build example
16+ if (BUILD_EXAMPLE)
17+ add_executable (example "${CMAKE_CURRENT_SOURCE_DIR} /src/example.c" )
18+ target_include_directories (example PRIVATE "${CMAKE_BINARY_DIR} /include" )
19+ endif ()
20+
1221
1322# Install
1423# Includes
1524# PERMISSIONS 0644
16- install (FILES "${output_includedir} /cppp/cppp-platform.h"
17- DESTINATION "${install_includedir} "
25+ install (FILES "${CMAKE_BINARY_DIR} /include /cppp/cppp-platform.h"
26+ DESTINATION "${CMAKE_INSTALL_PREFIX} /include "
1827 RENAME "cppp/cppp-platform.h"
1928 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ )
Original file line number Diff line number Diff line change 1- # Introduction
2- cppp-platform is a portable platform check library for C+++.
1+ # cppp-platfrom -- Portable platform check library
2+
3+ ## Build
4+
5+ ### Dependencies
36
4- # Build
5- ## Dependence
67+ CMake (version >= 3.10)
78
8- ## Command
9+ ### Command
10+
911``` shell
1012mkdir build
1113cd build
1214cmake .. -DCMAKE_INSTALL_PREFIX=[[PREFIX]]
15+ # If you want to build the example, add -DBUILD_EXAMPLE=ON
1316cmake --build .
1417cmake --install .
1518```
1619
17- # Example
18- After install, you can use cppp-platform in C/C++
19- ``` c
20- #include < cppp/cppp-platform.h>
21- #include < stdio.h>
22- int main ()
23- {
24- if(__has_windows__)
25- {
26- printf ("Compile in Windows!\n");
27- }
28- else
29- {
30- printf("Compile non-Windows!\n");
31- }
32- printf("Target arch:%s\n",__ arch__ );
33- printf("Target arch name:%s\n",__ arch_name__ );
34- printf("Pointer width:%d\n",__ POINTER_WIDTH__ );
35- }
36- ```
20+ ## Documentation
3721
38- # Manual
39- [ User Manual] ( doc/doc.md )
22+ [ Documentation] ( doc/doc.md )
Original file line number Diff line number Diff line change 1+ #include <cppp/cppp-platform.h>
2+
3+ #include <stdio.h>
4+ #include <stdlib.h>
5+
6+ int main (int argc , char * argv [])
7+ {
8+ if (argc != 1 )
9+ {
10+ fprintf (stderr , "Usage: %s\n" , argv [0 ]);
11+ return EXIT_FAILURE ;
12+ }
13+
14+ if (__has_windows__ )
15+ {
16+ printf ("Running on Windows!\n" );
17+ }
18+ else
19+ {
20+ printf ("Running non-Windows!\n" );
21+ }
22+ printf ("Target architcture id: %d\n" , __arch__ );
23+ printf ("Target arch name: %s\n" , __arch_name__ );
24+ printf ("Pointer width: %d\n" , __POINTER_WIDTH__ );
25+
26+ return EXIT_SUCCESS ;
27+ }
You can’t perform that action at this time.
0 commit comments