mirror of
https://github.com/Kitware/CMake.git
synced 2026-06-28 10:48:07 +00:00
PellesC: Add minimal support for this C compiler
Add bare minimum functionality to compile C code and link on Windows. Explicitly label tests that are expected to work with `CFLAGS=-Ze`. Leave out documentation for now because this is not usable in general. Issue: #21536 Inspired-by: Serguei E. Leontiev <leo@sai.msu.ru>
This commit is contained in:
@@ -482,6 +482,7 @@ endif()
|
||||
|
||||
if(CMake_TEST_EXTERNAL_CMAKE)
|
||||
set(KWIML_TEST_ENABLE 1)
|
||||
set(KWIML_TEST_LABELS "PellesC")
|
||||
add_subdirectory(Utilities/KWIML)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
||||
|
||||
#if defined(__STDC_VERSION__)
|
||||
# define C_STD __STDC_VERSION__
|
||||
#elif defined(__POCC_STDC_VERSION__)
|
||||
# define C_STD __POCC_STDC_VERSION__
|
||||
#elif defined(__STDC__) || defined(__clang__) || defined(_MSC_VER) || \
|
||||
defined(__ibmxl__) || defined(__IBMC__) || defined(__RENESAS__)
|
||||
# define C_STD 1
|
||||
|
||||
@@ -74,6 +74,7 @@ function(compiler_id_detection outvar lang)
|
||||
list(APPEND ordered_compilers
|
||||
TinyCC
|
||||
Bruce
|
||||
PellesC
|
||||
)
|
||||
endif()
|
||||
list(APPEND ordered_compilers
|
||||
|
||||
@@ -108,6 +108,11 @@ elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^x(Open)?W
|
||||
set(_CMAKE_AR_NAMES "wlib")
|
||||
list(APPEND _CMAKE_TOOL_VARS LINKER AR)
|
||||
|
||||
elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xPellesC")
|
||||
set(_CMAKE_LINKER_NAMES "polink")
|
||||
set(_CMAKE_AR_NAMES "polib")
|
||||
list(APPEND _CMAKE_TOOL_VARS LINKER AR)
|
||||
|
||||
elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$")
|
||||
# Detect the `<lang>` compiler name
|
||||
get_filename_component(__iar_selected_compiler "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" NAME)
|
||||
|
||||
8
Modules/Compiler/PellesC-C.cmake
Normal file
8
Modules/Compiler/PellesC-C.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file LICENSE.rst or https://cmake.org/licensing for details.
|
||||
|
||||
include (Compiler/PellesC)
|
||||
__compiler_pellesc(C)
|
||||
|
||||
set(CMAKE_C_OUTPUT_EXTENSION ".obj")
|
||||
set(CMAKE_C_VERBOSE_FLAG "-V2")
|
||||
8
Modules/Compiler/PellesC-DetermineCompiler.cmake
Normal file
8
Modules/Compiler/PellesC-DetermineCompiler.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file LICENSE.rst or https://cmake.org/licensing for details.
|
||||
|
||||
set(_compiler_id_pp_test "defined(__POCC__)")
|
||||
|
||||
set(_compiler_id_version_compute "
|
||||
# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__POCC__/100)
|
||||
# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__POCC__%100)")
|
||||
7
Modules/Compiler/PellesC.cmake
Normal file
7
Modules/Compiler/PellesC.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file LICENSE.rst or https://cmake.org/licensing for details.
|
||||
include_guard()
|
||||
|
||||
macro(__compiler_pellesc lang)
|
||||
set(CMAKE_${lang}_LINK_MODE LINKER)
|
||||
endmacro ()
|
||||
5
Modules/Platform/Windows-PellesC-C.cmake
Normal file
5
Modules/Platform/Windows-PellesC-C.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file LICENSE.rst or https://cmake.org/licensing for details.
|
||||
|
||||
include (Platform/Windows-PellesC)
|
||||
__windows_compiler_pellesc(C)
|
||||
24
Modules/Platform/Windows-PellesC.cmake
Normal file
24
Modules/Platform/Windows-PellesC.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file LICENSE.rst or https://cmake.org/licensing for details.
|
||||
include_guard()
|
||||
|
||||
set(CMAKE_LIBRARY_PATH_FLAG "-libpath:")
|
||||
set(CMAKE_LINK_LIBRARY_FLAG "")
|
||||
|
||||
macro(__windows_compiler_pellesc lang)
|
||||
set(CMAKE_${lang}_COMPILE_OBJECT
|
||||
"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -Fo<OBJECT> -c <SOURCE>")
|
||||
|
||||
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <LINK_FLAGS> -out:<TARGET> <OBJECTS>")
|
||||
|
||||
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_LINKER> <OBJECTS> -out:<TARGET> -implib:<TARGET_IMPLIB> -dll -version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_FLAGS> <LINK_LIBRARIES>")
|
||||
set(CMAKE_${lang}_CREATE_SHARED_MODULE "${CMAKE_${lang}_CREATE_SHARED_LIBRARY}")
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "")
|
||||
|
||||
set(CMAKE_${lang}_LINK_EXECUTABLE
|
||||
"<CMAKE_LINKER> <OBJECTS> -out:<TARGET> -implib:<TARGET_IMPLIB> -version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_FLAGS> <LINK_LIBRARIES>")
|
||||
|
||||
set(CMAKE_${lang}_CREATE_WIN32_EXE "-subsystem:windows")
|
||||
set(CMAKE_${lang}_CREATE_CONSOLE_EXE "-subsystem:console")
|
||||
endmacro()
|
||||
@@ -530,6 +530,7 @@ if(BUILD_TESTING)
|
||||
endif()
|
||||
|
||||
ADD_TEST_MACRO(COnly COnly)
|
||||
set_property(TEST COnly APPEND PROPERTY LABELS "PellesC")
|
||||
ADD_TEST_MACRO(CxxOnly CxxOnly)
|
||||
ADD_TEST_MACRO(CxxSubdirC CxxSubdirC)
|
||||
ADD_TEST_MACRO(OutDir runtime/OutDir)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "libc2.h"
|
||||
|
||||
#ifdef __POCC__
|
||||
CM_TEST_LIB_EXPORT
|
||||
#endif
|
||||
float LibC2Func(void)
|
||||
{
|
||||
return 1.0;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#ifdef __POCC__
|
||||
# pragma warn(disable : 2801) /* Store to a non-writable location. */
|
||||
#endif
|
||||
|
||||
int main(int argc, char const* argv[])
|
||||
{
|
||||
#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
|
||||
|
||||
Reference in New Issue
Block a user