Skip to content

Commit

Permalink
Update CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed May 19, 2021
1 parent e578f50 commit 4d5f514
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
33 changes: 25 additions & 8 deletions examples/xcpsim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
cmake_minimum_required(VERSION 3.10)

project(xcpsim LANGUAGES C)


if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "Build type not specified: defaulting to release.")
endif()


IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_C_STANDARD 11)
ELSEIF(CMAKE_C_COMPILER_ID MATCHES "Clang")
Expand All @@ -25,6 +22,7 @@ set(SOURCES
../../src/xcp_checksum.c
../../src/xcp_daq.c
../../src/xcp_util.c
../../src/hw/terminal.c
../../flsemu/common.c
app_config.c
appl1.c
Expand All @@ -33,25 +31,43 @@ set(SOURCES

if(WIN32)
set(_PS "win")
set(ADD_LIBS
"ws2_32"
)
list(APPEND SOURCES "../../src/hw/win/hw.c")
list(APPEND SOURCES "../../flsemu/win/flsemu.c")
elseif(UNIX)
set(_PS "linux")
list(APPEND SOURCES "../../src/hw/linux/hw.c ")
list(APPEND SOURCES "../../src/hw/linux/hw.c")
list(APPEND SOURCES "../../flsemu/posix/flsemu.c")
list(APPEND SOURCES "../../src/tl/eth/linuxeth.c")
set(ADD_LIBS
"pthread"
"rt"
)
endif(WIN32)


if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
add_definitions(-D_GNU_SOURCE)
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -ffunction-sections")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -ffunction-sections")

if ("${PROFILE}" STREQUAL "ON")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg -fprofile-arcs -ftest-coverage --coverage")
endif()

list(APPEND CMAKE_C_FLAGS -DEther)
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -D_DEBUG -Og -DFORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -fstack-check -fsanitize=address -static-libasan")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNDEBUG -O3")
endif()

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DETHER")

add_executable(xcp_sim ${SOURCES})
target_include_directories(
Expand All @@ -61,4 +77,5 @@ target_include_directories(
../../inc
../../flsemu
)

target_link_libraries(xcp_sim ${ADD_LIBS})
target_compile_features(xcp_sim PRIVATE c_std_11)
1 change: 0 additions & 1 deletion flsemu/posix/flsemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* s. FLOSS-EXCEPTION.txt
*/

#define _GNU_SOURCE
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
Expand Down

0 comments on commit 4d5f514

Please sign in to comment.