I am trying to add the -lWs2_32
compiler flag for my CMake configuration.
I have tried using both add_compile_options(-lWs2_32)
and set(CMAKE_CXX_FLAGS -lWs2_32)
The flag is necessary for the HTTPRequest.hpp
library.
Directory structure:
project
└───include
│ └───chessgame
│ │ chess.cc
│ │ chess.h
│ └───HTTPRequest
│ │ HTTPRequest.hpp
│ └───nlohmann
│ │ json.hpp
└───src
│ ...
CMakeLists.txt:
cmake_minimum_required(VERSION 3.20.1)
project(chessengine C CXX)
set(HEADERS
src/constants.hpp
src/consoleapp.hpp
src/opening.hpp
src/middlegame.hpp
src/endgame.hpp
src/engine.hpp
)
set(SOURCES
src/consoleapp.cpp
src/opening.cpp
src/middlegame.cpp
src/endgame.cpp
src/engine.cpp
src/main.cpp
)
# Neither of these work
add_compile_options(-lWs2_32)
set(CMAKE_CXX_FLAGS -lWs2_32)
add_executable(engine ${HEADERS} ${SOURCES})
add_subdirectory(include)
target_link_libraries(engine json chess httprequest)
CMakeLists in include directory:
add_library(chess chessgame/chess.cc chessgame/chess.h)
add_library(httprequest INTERFACE HTTPRequest)
add_library(json INTERFACE nlohmann)