-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
48 lines (39 loc) · 1.52 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
cmake_minimum_required(VERSION 3.10)
project(genexec)
if (UNIX AND NOT APPLE)
message(STATUS ">>> Unix environment detected")
set(myOSOutput "-linux.lin")
set(dest "instdir-linux")
elseif (APPLE)
execute_process(COMMAND brew install gcc --force-bottle)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS ">>> Clang compiler detected")
# Add any Clang-specific settings or flags here
set(CMAKE_CXX_STANDARD 11)
endif()
set(myOSOutput "-macos.mac")
set(dest "instdir-macos")
find_program(GPP_EXECUTABLE g++)
if(GPP_EXECUTABLE)
set(CMAKE_CXX_COMPILER "/usr/local/bin/g++-11")
set(CMAKE_C_COMPILER "/usr/local/bin/gcc-11")
endif()
elseif (WIN32)
message(STATUS ">>> Windows environment detected")
set(CMAKE_CXX_FLAGS "-w")
set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lwsock32 -lws2_32 ${CMAKE_CXX_STANDARD_LIBRARIES}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
set(myOSOutput "-windows")
set(dest "instdir-windows")
else()
message(STATUS ">>> Unknown")
set(myOSOutput "-macos.mac")
set(dest "instdir-macos")
endif()
file(GLOB SRC_FILES *.cpp)
foreach(srcfile ${SRC_FILES})
get_filename_component(srcname1 ${srcfile} NAME)
string(REPLACE ".cpp" ${myOSOutput} srcname ${srcname1})
add_executable(${srcname} ${srcfile})
install(TARGETS ${srcname} DESTINATION ${dest})
endforeach(srcfile ${SRC_FILES})