title: How do I configure CMake file to add compiler flag?
body: <p>I am trying to add the <code>-lWs2_32</code> compiler flag for my CMake configuration.
  I have tried using both <code>add_compile_options(-lWs2_32)</code> and <code>set(CMAKE_CXX_FLAGS -lWs2_32)</code></p>
  <p>The flag is necessary for the <code>HTTPRequest.hpp</code> library.</p>
  <p>Directory structure:</p>
  <pre><code>project
  └───include
  │   └───chessgame
  │       │   chess.cc
  │       │   chess.h
  │   └───HTTPRequest
  │       │   HTTPRequest.hpp
  │   └───nlohmann
  │       │   json.hpp
  └───src
      │   ...
  </code></pre>
  <p>CMakeLists.txt:</p>
  <pre><code>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)
  </code></pre>
  <p>CMakeLists in include directory:</p>
  <pre><code>add_library(chess chessgame/chess.cc chessgame/chess.h)
  add_library(httprequest INTERFACE HTTPRequest)
  add_library(json INTERFACE nlohmann)
  </code></pre>