Skip to content

Commit

Permalink
cmake is shit
Browse files Browse the repository at this point in the history
  • Loading branch information
abbycin committed Dec 31, 2020
1 parent 39c97a5 commit fa603b9
Show file tree
Hide file tree
Showing 25 changed files with 59 additions and 83 deletions.
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.18)
project(tools)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -pedantic-errors -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Werror -pedantic-errors")

file(GLOB items RELATIVE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/*)
foreach(item ${items})
string(REGEX MATCH "^[^\.].*" dot ${item})
if(("${dot}" STREQUAL "") OR (${item} STREQUAL "build"))
continue()
endif()
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${item})
message(STATUS ${item})
add_subdirectory(${PROJECT_SOURCE_DIR}/${item})
endif()
endforeach()
2 changes: 1 addition & 1 deletion loop_per_thread/Makefile → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ all:
cd build && cmake -DCMAKE_BUILD_TYPE=$(FLAG) .. && cmake --build . -- -j$(JOBS)

clean:
@rm -rf bin build lib
@rm -rf build
10 changes: 1 addition & 9 deletions bloom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
cmake_minimum_required(VERSION 3.15)
project(bloom)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include_directories(${PROJECT_SOURCE_DIR}/murmur3)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/murmur3)
add_subdirectory(murmur3)
add_executable(bloom bloom.h main.cpp)
target_link_libraries(bloom murmur3)
1 change: 1 addition & 0 deletions cfg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_executable(hash test_hash.cpp)
3 changes: 3 additions & 0 deletions channel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
find_package(Threads)
add_executable(mpsc test.cpp)
target_link_libraries(mpsc Threads::Threads)
4 changes: 0 additions & 4 deletions coroutine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
cmake_minimum_required(VERSION 3.10)
project(coroutine)

set(CMAKE_CXX_STANDARD 17)
enable_language(ASM_NASM)

set(SWITCH_STACK switch_stack.asm)
Expand Down
13 changes: 1 addition & 12 deletions crypt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
cmake_minimum_required(VERSION 3.6)
project(crypto CXX)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -Wall")
SET(BUILD_SHARED_LIBRARIES OFF)
SET(CMAKE_EXE_LINKER_FLAGS "-static")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")

add_executable(decrypt decrypt.cpp)

add_executable(encrypt encrypt.cpp)
add_executable(encrypt encrypt.cpp)
2 changes: 1 addition & 1 deletion crypt/encrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ int main(int argc, char* argv[])
of.write("\t", 1);
of << res;
of.close();
};
}
1 change: 1 addition & 0 deletions fake_variant/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_executable(fake_variant test.cpp)
3 changes: 3 additions & 0 deletions file_sort/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(file_sort_bit bit.cpp)
add_executable(file_sort_bs bs.cpp)
add_executable(file_sort_rand rand.cpp)
6 changes: 3 additions & 3 deletions file_sort/bs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class Bigdata
FILE* fd = fopen(out_.c_str(), "w");
if(fd == nullptr)
failure(__func__, __LINE__);
FILE* fds[count_];
long data[count_];
bool done[count_];
std::vector<FILE*> fds(count_);
std::vector<long> data(count_);
std::vector<bool> done(count_);
char name[50];
for(long i = 0; i < count_; ++i)
{
Expand Down
1 change: 1 addition & 0 deletions fm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_executable(functor_map test.cpp)
5 changes: 0 additions & 5 deletions form_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
cmake_minimum_required(VERSION 3.10)
project(form_parser)

set(CMAKE_CXX_STANDARD 11)

add_executable(form_parser form_parser.h main.cpp)
5 changes: 0 additions & 5 deletions json/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
cmake_minimum_required(VERSION 3.19)
project(json)

set(CMAKE_CXX_STANDARD 17)

add_executable(json json.h main.cpp)
10 changes: 1 addition & 9 deletions logging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
cmake_minimum_required(VERSION 3.8)
project(logging)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -pedantic-errors -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Werror -pedantic-errors")

set(SOURCE_FILES
logging.h test.cpp)
set(SOURCE_FILES logging.h test.cpp)

add_executable(logging_test ${SOURCE_FILES})
target_link_libraries(logging_test pthread)
Expand Down
8 changes: 0 additions & 8 deletions loop_per_thread/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
cmake_minimum_required(VERSION 3.6)
project(loop_per_thread CXX)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -Wall")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
find_package(Boost 1.61 REQUIRED system)

add_executable(server server.cpp)
Expand Down
9 changes: 7 additions & 2 deletions loop_per_thread/server1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#include <thread>
#include <boost/asio.hpp>

class Service : boost::noncopyable, public std::enable_shared_from_this<Service>
class Service : public std::enable_shared_from_this<Service>
{
public:
Service(const Service&) = delete;
Service& operator=(const Service&) = delete;
Service(std::shared_ptr<boost::asio::ip::tcp::socket> sock) : socket_(sock), msg_("pong\n") {}

static std::shared_ptr<Service> make_service(std::shared_ptr<boost::asio::ip::tcp::socket> sock)
Expand Down Expand Up @@ -64,7 +66,7 @@ class Service : boost::noncopyable, public std::enable_shared_from_this<Service>
}
};

class Acceptor : boost::noncopyable
class Acceptor
{
public:
Acceptor(boost::asio::io_service* io, boost::asio::ip::tcp::endpoint&& ep)
Expand All @@ -73,6 +75,9 @@ class Acceptor : boost::noncopyable
std::atomic_init(&is_quit_, false);
}

Acceptor(const Acceptor&) = delete;
Acceptor& operator=(const Acceptor&) = delete;

void start()
{
acceptor_.listen(SOMAXCONN); // default SOMAXCONN is 128
Expand Down
Empty file added meta/CMakeLists.txt
Empty file.
8 changes: 1 addition & 7 deletions optional/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
cmake_minimum_required(VERSION 3.10)
project(optional CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(optional optional.h main.cpp)
add_executable(optional optional.h main.cpp)
5 changes: 0 additions & 5 deletions rbtree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
cmake_minimum_required(VERSION 3.7)
project(rbtree)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

set(SOURCE_FILES test.cpp)
add_executable(rbtree ${SOURCE_FILES})
7 changes: 0 additions & 7 deletions router/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
cmake_minimum_required(VERSION 3.15)
project(router)

set(CMAKE_CXX_STANDARD 20)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

add_executable(trie trie.cc)
add_executable(radix radix.cc)
add_executable(3way 3way.cc)
Expand Down
3 changes: 3 additions & 0 deletions signal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(signal_call signal_call_test.cpp)
add_executable(signal1 signal1.cpp)
add_executable(signal2 signal2.cpp)
6 changes: 6 additions & 0 deletions string_ext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_executable(string_ext test.cpp)
add_custom_command(
TARGET string_ext POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/ip.txt
${CMAKE_CURRENT_BINARY_DIR}/ip.txt)
3 changes: 3 additions & 0 deletions threadpool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
find_package(Threads)
add_executable(threadpool test_threadpool.cpp)
target_link_libraries(threadpool Threads::Threads)
6 changes: 1 addition & 5 deletions variant/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
cmake_minimum_required(VERSION 3.7)
project(variant)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES variant.h test.cpp)
add_executable(variant ${SOURCE_FILES})
add_executable(variant ${SOURCE_FILES})

0 comments on commit fa603b9

Please sign in to comment.