[C] Enabled wchar_t and utf-8 by default

This commit is contained in:
seleznevae 2019-08-29 09:12:58 +03:00
parent 5bfabee696
commit 64dbd4c2c4
9 changed files with 79 additions and 24 deletions

View File

@ -14,14 +14,14 @@ main_task:
# Basic c build
- cd lib
- cc -Wall -Wextra -Werror --std=gnu89 -DFT_CONGIG_HAVE_WCHAR fort.c -c -o fort.o
- cc -Wall -Wextra -Werror --std=gnu89 fort.c -c -o fort.o
- rm fort.o
- cd ..
# Basic c++ build
- cd lib
- cp fort.c fort.cpp
- c++ -Wall -Wextra -Werror -DFT_CONGIG_HAVE_WCHAR fort.cpp -c -o fort.o
- c++ -Wall -Wextra -Werror fort.cpp -c -o fort.o
- rm fort.o
- rm fort.cpp
- cd ..
@ -47,10 +47,10 @@ main_task:
- cd ..
- rm -r build/*
# Test without WCHAR support
# Test without WCHAR and UTF-8 support
- mkdir -p build
- cd build
- cmake .. -DFORT_ENABLE_WCHAR=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}"
- cmake .. -DFORT_ENABLE_WCHAR=OFF -DFORT_ENABLE_UTF8=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}"
- cmake --build . --target all
- ls
- ctest -VV

View File

@ -144,7 +144,7 @@ script:
# basic build with old c standard (use gnu89 instead of c89 because some functions are not defines in c89)
- cd lib
- ${CC} -Wall -Wextra -Werror --std=gnu89 -DFT_CONGIG_HAVE_WCHAR fort.c -c -o fort.o
- ${CC} -Wall -Wextra -Werror --std=gnu89 fort.c -c -o fort.o
- rm fort.o
- cd ..
@ -199,12 +199,12 @@ script:
- ls
- ctest -VV
# Test without WCHAR support
# Test without WCHAR and UTF-8 support
- cd ..
- rm -r build/*
- mkdir -p build
- cd build
- cmake .. -DFORT_ENABLE_WCHAR=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}"
- cmake .. -DFORT_ENABLE_WCHAR=OFF -DFORT_ENABLE_UTF8=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_STANDARD=99 -DCMAKE_CXX_STANDARD=11 -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}"
- cmake --build . --target all
- ls
- ctest -VV

View File

@ -14,6 +14,7 @@ include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
option(FORT_ENABLE_ASTYLE "Enable astyle" OFF)
option(FORT_ENABLE_WCHAR "Enable wchar support" ON)
option(FORT_ENABLE_UTF8 "Enable utf8 support" ON)
set(FORT_BUILD_TYPE "common" CACHE STRING "Build type")
set_property(CACHE FORT_BUILD_TYPE PROPERTY STRINGS
@ -137,11 +138,16 @@ endforeach()
# ------------------------------------------------------------------------------
# Add WChar support for the build
# ------------------------------------------------------------------------------
if(FORT_ENABLE_WCHAR)
add_definitions(-DFT_CONGIG_HAVE_WCHAR)
if(NOT FORT_ENABLE_WCHAR)
add_definitions(-DFT_CONGIG_DISABLE_WCHAR)
endif()
if(NOT FORT_ENABLE_UTF8)
add_definitions(-DFT_CONGIG_DISABLE_UTF8)
endif()
set(FORT_HAVE_WCHAR "${FORT_ENABLE_WCHAR}" CACHE STRING "fort option")
set(FORT_HAVE_UTF8 "${FORT_ENABLE_UTF8}" CACHE STRING "fort option")
# ------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
option(FORT_HAVE_WCHAR "Enable wchar support" ON)
option(FORT_HAVE_UTF8 "Enable UTF8 support" ON)
add_library(fort
fort.c)
@ -12,10 +13,17 @@ set_target_properties(fort
PROPERTIES VERSION ${libfort_VERSION}
SOVERSION ${libfort_SOVERSION})
if(FORT_HAVE_WCHAR)
if(NOT FORT_HAVE_WCHAR)
target_compile_definitions(fort
PRIVATE
-DFT_CONGIG_HAVE_WCHAR
-DFT_CONGIG_DISABLE_WCHAR
)
endif()
if(NOT FORT_HAVE_UTF8)
target_compile_definitions(fort
PRIVATE
-DFT_CONGIG_DISABLE_UTF8
)
endif()

View File

@ -53,21 +53,37 @@ SOFTWARE.
/*****************************************************************************
* Configuration
*****************************************************************************/
///**
// * libfort configuration macros
// * (to enable/disable some options this macros should be defined/undefined)
// */
///** #define FT_CONGIG_HAVE_WCHAR */
//#if defined(FT_CONGIG_HAVE_WCHAR)
//#define FT_HAVE_WCHAR
//#endif
//#define FT_CONGIG_HAVE_UTF8
//#if defined(FT_CONGIG_HAVE_UTF8)
//#define FT_HAVE_UTF8
//#endif
/**
* libfort configuration macros
* (to enable/disable some options this macros should be defined/undefined)
* (to disable wchar_t/utf-8 support this macros should be defined)
*/
/** #define FT_CONGIG_HAVE_WCHAR */
/** #define FT_CONGIG_DISABLE_WCHAR */
/** #define FT_CONGIG_DISABLE_UTF8 */
#if defined(FT_CONGIG_HAVE_WCHAR)
#if !defined(FT_CONGIG_DISABLE_WCHAR)
#define FT_HAVE_WCHAR
#endif
#define FT_CONGIG_HAVE_UTF8
#if defined(FT_CONGIG_HAVE_UTF8)
#if !defined(FT_CONGIG_DISABLE_UTF8)
#define FT_HAVE_UTF8
#endif
/*****************************************************************************
* RETURN CODES
*****************************************************************************/

View File

@ -1,4 +1,5 @@
option(FORT_HAVE_WCHAR "Enable wchar support" ON)
option(FORT_HAVE_UTF8 "Enable UTF8 support" ON)
option(FORT_TEST_BUILD "Export some internal symbols for tests" ON)
add_library(fort_dev
@ -17,10 +18,17 @@ target_include_directories(fort_dev
${CMAKE_CURRENT_SOURCE_DIR}
)
if(FORT_HAVE_WCHAR)
if(NOT FORT_HAVE_WCHAR)
target_compile_definitions(fort_dev
PRIVATE
-DFT_CONGIG_HAVE_WCHAR
-DFT_CONGIG_DISABLE_WCHAR
)
endif()
if(NOT FORT_HAVE_UTF8)
target_compile_definitions(fort_dev
PRIVATE
-DFT_CONGIG_DISABLE_UTF8
)
endif()

View File

@ -53,21 +53,37 @@ SOFTWARE.
/*****************************************************************************
* Configuration
*****************************************************************************/
///**
// * libfort configuration macros
// * (to enable/disable some options this macros should be defined/undefined)
// */
///** #define FT_CONGIG_HAVE_WCHAR */
//#if defined(FT_CONGIG_HAVE_WCHAR)
//#define FT_HAVE_WCHAR
//#endif
//#define FT_CONGIG_HAVE_UTF8
//#if defined(FT_CONGIG_HAVE_UTF8)
//#define FT_HAVE_UTF8
//#endif
/**
* libfort configuration macros
* (to enable/disable some options this macros should be defined/undefined)
* (to disable wchar_t/utf-8 support this macros should be defined)
*/
/** #define FT_CONGIG_HAVE_WCHAR */
/** #define FT_CONGIG_DISABLE_WCHAR */
/** #define FT_CONGIG_DISABLE_UTF8 */
#if defined(FT_CONGIG_HAVE_WCHAR)
#if !defined(FT_CONGIG_DISABLE_WCHAR)
#define FT_HAVE_WCHAR
#endif
#define FT_CONGIG_HAVE_UTF8
#if defined(FT_CONGIG_HAVE_UTF8)
#if !defined(FT_CONGIG_DISABLE_UTF8)
#define FT_HAVE_UTF8
#endif
/*****************************************************************************
* RETURN CODES
*****************************************************************************/

View File

@ -1,4 +1,5 @@
option(FORT_HAVE_WCHAR "Enable wchar support" ON)
option(FORT_HAVE_UTF8 "Enable UTF8 support" ON)
option(FORT_TEST_BUILD "Export some internal symbols for tests" ON)

View File

@ -14,7 +14,7 @@
#define THEN(...)
#define SCENARIO(...)
#if defined(FT_CONGIG_HAVE_WCHAR)
#if !defined(FT_CONGIG_DISABLE_WCHAR)
#define FT_HAVE_WCHAR
#endif